localhost:4200 (Angular): not working and fixes
Port 4200 is the Angular dev server. How to start it, change the port and fix common errors.
Open this address: http://localhost:4200This opens on your own computer. It only works if the program is running.
localhost:4200 is the default address for an Angular app started with ng serve. If it will not open, the server is not running or the port is taken.
What runs on localhost:4200
- Angular dev server started with
ng serve
Commands to start and test port 4200
ng serveng serve --openng serve --port 4300npx ng serveFind what is using port 4200
Run these in a terminal on your computer. Nothing is sent to this site.
If localhost:4200 will not open
- Open ng serve from another computer, phone or container
- Angular’s ng serve listens on localhost by default. Use
ng serve --host 0.0.0.0to listen on all addresses. Newer Angular versions also check the host name, so you may need--allowed-hoststo name the hosts the dev server should answer. - Changes are not picked up (WSL, network drive, container)
- File watching can miss changes there.
ng serve --poll 2000turns on polling with a 2000 millisecond interval. - The app calls an API and the browser blocks it
- Point the dev server at a proxy file with
ng serve --proxy-config proxy.conf.json, so requests to your API go through the dev server instead of straight from the browser. - HTTPS in development
ng serve --sslserves the app over HTTPS. The browser will warn about the certificate in the same way as on any local HTTPS address.- Port 4200 is already in use
- Angular offers another port, or stop the old server using the tool below.
- ng is not recognized
- The Angular CLI is missing. Install it with
npm install -g @angular/clior runnpx ng serveinside the project. - Blank page
- Look at the terminal for compile errors, and the browser console (F12) for runtime errors.
Other ports like 4200
| Port | Usually used by |
|---|---|
| localhost:3000 | React, Next.js, Express |
| localhost:5173 | Vite dev server |
| localhost:5000 | Flask |
| localhost:8000 | Django, PHP, Python |
| localhost:8080 | Tomcat, Spring Boot, Docker |
| localhost:8888 | Jupyter Notebook |
| localhost:9000 | PHP-FPM, SonarQube |
Questions about localhost:4200
- What is localhost:4200?
- The default address of the Angular development server, started with ng serve.
- How do I change the Angular port?
- Run ng serve --port 4300, or set the port under the serve options in angular.json.