# Angular CLI: Port 4200 is already in use. Use '--port' to specify a different port

**Code:** `Port 4200 is already in use` · **Category:** Angular · **Seen on:** Angular, Angular CLI

Another process is already listening on the dev-server port, often an earlier `ng serve` that was not stopped.

## Meaning

Only one process can use a port. Stop the old dev server, or pick another port with `--port` (use `--port 0` for a random free one). On Linux/macOS find the process with `lsof`; on Windows use `netstat`.

## Common causes

- Previous `ng serve` still running in another terminal or background
- Another app (Docker, another dev server) using 4200
- Crashed process left a zombie
- IDE running `ng serve` automatically
- Port reserved by Windows (excluded port range)

## Quick fix

1. Run on another port: `ng serve --port 4300`
2. Stop the old process
3. Free the port with `lsof` / `taskkill`

## Detailed fix by platform

### Linux

1. `lsof -i :4200` then `kill <PID>`
2. macOS: same commands; or `npx kill-port 4200`

### Windows

1. `netstat -ano | findstr :4200` then `taskkill /PID <pid> /F`

## Code examples

### Find and free the port

```bash
lsof -i :4200                 # shows the PID
kill -9 <PID>
ng serve --port 4300          # or pick another port
```

## How to diagnose

1. **Process** — What is listening on 4200?
2. **Terminals** — Another ng serve running?
3. **Alternative** — Can you use --port?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng-serve-port-4200-in-use)
