localhost:4200
The address of the Angular development server on your own computer. Running ng serve starts it on port 4200.
Updated November 2026 · 3 min read
-
Written by
Andrian Valeanu
Founder of Pulsetic
-
Reviewed by
Ionut Caval
Technical reviewer
The short version: http://localhost:4200 works only while ng serve is running and has finished compiling. If the page will not load, the server is not running or the build failed. If Angular says the port is already in use, an earlier ng serve is still alive: stop it, or start the new one with ng serve --port 4201.
- Used by
- Angular CLI (
ng serve), Ember CLI - Full address
http://localhost:4200- If the port is busy
- Angular asks whether to use another port
- Most common problem
- A previous
ng servestill running
What is localhost:4200?
localhost:4200 is the Angular development server on your own computer. When you run ng serve, the Angular CLI builds the app, serves it on port 4200 and rebuilds it every time you save a file.
The number is simply the default the Angular CLI inherited from Ember CLI, which also serves on 4200. Nothing else common uses it, so a conflict on this port is nearly always a second copy of your own dev server.
The page is available only on your machine and only while the command runs. It is a development tool, not a way to host the app.
What runs on port 4200
Two tools use port 4200 by default. The last column shows how to move each one to a different port.
| Program | How it starts | Change the port |
|---|---|---|
| Angular CLI | ng serve or npm start | ng serve --port 4201, or "port": 4201 under serve.options in angular.json |
| Ember CLI | ember serve | ember serve --port 4201 |
| Nx (Angular apps) | nx serve my-app | nx serve my-app --port 4201 |
Why localhost:4200 will not load
ng serveis not running. The browser shows "localhost refused to connect". The command has to stay running in a terminal the whole time you work.- The first build has not finished. A large app takes a while to compile. The server accepts connections only after the terminal reports that the build completed.
- The build failed. A TypeScript or template error stops the app from loading. The terminal lists the file and line.
- Port 4200 is already in use. Angular prints
Port 4200 is already in use. Would you like to use a different port?An olderng serveis still running somewhere. - You are opening it from another device or a container. The server listens only on localhost unless you start it with
ng serve --host 0.0.0.0. - A blank page. The server is fine and the app threw an error in the browser. The developer console shows it.
Find what is using port 4200
One command shows whether a program is listening on the port, and which one. No output means nothing is listening, and that is exactly when the browser says the connection was refused.
On Linux, ss -ltnp | grep :4200 gives the same answer. Add sudo on macOS or Linux to see programs owned by another user. Stopping a process ends whatever it was doing, so check what it is before you stop it.
How to fix it
If the page will not load
- Run
ng servein the project folder and wait for the line that says the app is being served onhttp://localhost:4200/. - Fix any compile errors the terminal lists, then let it rebuild.
- If you are inside Docker or a remote machine, use
ng serve --host 0.0.0.0and publish the port. - If the page is blank, open the browser console.
If port 4200 is already in use
- Answer yes to the prompt to let Angular pick a free port, or
- Find the old process with the commands in the section above and stop it, or
- Start on a port you choose:
ng serve --port 4201.
From localhost to production
ng serve is for development only. For production you run ng build and put the output on a web server or hosting platform, where it answers on ports 80 and 443. The API the app calls moves from a localhost address to a public one at the same time, and both need to stay reachable for the app to work.
To test a deployed address by hand, the free bulk URL status checker shows the status code and redirects for a list of URLs, and Is Website Down checks one from several countries. Neither can see localhost: like any service on the internet, they only reach public addresses.
Deployed it? Watch the public URL.
Pulsetic is website uptime monitoring. It cannot reach localhost, but once your app is live it checks the public URL from outside your network, confirms any failure from another region, then emails you.
10 monitors free, checked every 5 minutes, with email alerts on failure and recovery. No credit card.
Sources and further reading
The documentation and specifications this guide is written from.
Frequently asked questions
-
What is localhost:4200?
It is the Angular development server on your own computer.
ng servestarts it, and it stops when you end that command. -
How do I fix "Port 4200 is already in use"?
Another program, almost always an earlier
ng serve, holds the port. Stop it, or runng serve --port 4201to start on a different port. -
How do I change the default Angular port for good?
In
angular.json, add"port": 4201to theoptionsof theservetarget. Everyng servein that project then uses it. -
Can I use ng serve in production?
No. It is a development server with no production hardening. Build the app with
ng buildand serve the output from a real web server.
-
Know when your live website stops answering.
2-minute setup · Cancel any time
-
No credit card needed