Angular dev server default port: 4200

Angular dev server uses TCP port 4200 by default. ng serve checks the port before it starts. In a terminal it asks whether you want a different port and, if you agree, starts on a free port chosen by the operating system, which is not necessarily 4201.

Updated

Key facts

Default ports for Angular dev server
PortProtocolRoleCategory
4200TCPng serve dev serverFrontend

What happens when the port is busy

ng serve checks the port before it starts. In a terminal it asks whether you want a different port and, if you agree, starts on a free port chosen by the operating system, which is not necessarily 4201. Without a terminal, in a script or CI for example, it exits with an error that tells you to use --port. Read the URL the CLI prints before you open a browser tab.

Change the port

CLI flag
ng serve --port 4201

The app is then served at http://localhost:4201.

PORT environment variable
PORT=4201 ng serve

Angular 22 and later read PORT and log that they are using it. It overrides --port and the port in angular.json, so a PORT exported for another tool wins silently.

angular.json
{
  "projects": {
    "my-app": {
      "architect": {
        "serve": {
          "options": {
            "port": 4201
          }
        }
      }
    }
  }
}

Merge this into your existing serve target and keep its builder line. Current docs name @angular/build:dev-server, older projects use @angular-devkit/build-angular:dev-server.

Environment variable: PORT. Angular 22 and later use it when it is a number, and it overrides both --port and the port in angular.json. Before Angular 22 the dev server ignores it.

Bind address

ng serve listens on localhost by default (the host option defaults to localhost), so other devices on your network cannot reach it. Use --host, or the host option in the serve target, to change the address it listens on.

What else uses this port

No other tool in this dataset uses port 4200 as a default.

The dataset is the 12 tools on the ports index.

Find and free this port

These commands find the process that holds TCP port 4200 and stop it. They come from the Port in use command generator. PID_NUMBER stands for the process ID you read from the first command: replace it before you run the others.

macOS (zsh)
lsof -nP -iTCP:4200 -sTCP:LISTEN
ps -p PID_NUMBER -o pid,ppid,user,command
kill -TERM PID_NUMBER
Linux (bash)
ss -ltnp 'sport = :4200'
ps -p PID_NUMBER -o pid,ppid,user,command
kill -TERM PID_NUMBER
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 4200 -State Listen -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, State, OwningProcess
Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = PID_NUMBER" | Select-Object ProcessId, ParentProcessId, Name, CommandLine
Stop-Process -Id PID_NUMBER

Read the output of the second command before you stop anything, because the owner may be a container or another person’s process. Then run the first command again to confirm the port is free.

Next free ports

Counting up from 4200, the next three ports that no tool in this dataset uses as a default are 4201, 4202, and 4203. They are suggestions only: another program on your machine may hold any of them, so run the find command above before you choose one.

Collisions in practice

Nothing else among the front-end dev servers covered here defaults to 4200, so Angular mostly collides with itself: an earlier ng serve that never exited, a terminal tab closed without stopping it, an editor task left running, or a second checkout of the same repo. The prompt to pick another port appears only in an interactive terminal, so a task runner fails instead, and the replacement port is chosen by the operating system, not 4201. In a monorepo, give each app its own port in its serve options, and check for a stray PORT variable, which overrides it in Angular 22.

Frequently asked questions

How do I change the Angular dev server port permanently?

Add a port to the options of the serve target in angular.json. The options object holds the default values for that target, so ng serve picks the port up without a flag. The dev server’s options generally match the ng serve flags, and port defaults to 4200.

ng serve says port 4200 is in use. What should I do?

Find the process that holds it. If it is an old ng serve, stop it. If you want both running, answer yes to the prompt, or start the new one on a fixed port with ng serve --port 4201. In a script or CI there is no prompt: ng serve exits and tells you to use --port.

Why does ng serve ignore my --port?

In Angular 22 and later, a PORT environment variable overrides both --port and the port in angular.json, and the CLI logs a line saying it detected PORT. Run env | grep PORT, then unset it or set it to the value you want.

Is ng serve reachable from other devices?

Not by default. The host option defaults to localhost. Pass --host with the address to listen on if another device needs to reach the server, and only do so on a network you trust.

Sources

  1. Angular: ng serve reference (port, host)Official documentation, checked 13 October 2026
  2. Angular: serving apps for developmentOfficial documentation, checked 13 October 2026
  3. Angular: workspace configuration (serve target options)Official documentation, checked 13 October 2026
  4. Angular: published dev-server source (@angular/build@22.2.2 on npm)Editorial, checked 13 October 2026

Busy ports in Rig

When a start fails because a port is taken, Rig shows which process owns it when it can, and lets you reclaim the port or choose another. You do not need Rig to use this page.

Related

https://userig.app/ports/angular