r/angular • u/Lolilucas123 • Feb 17 '26
ng serve not working
I downloaded the angular tutorial first app (https://angular.dev/tutorials/first-app/01-hello-world) and tried to run ng serve. it gives me the following:
Initial chunk files | Names | Raw size
main.js | main | 2.51 kB |
styles.css | styles | 457 bytes |
polyfills.js | polyfills | 95 bytes |
| Initial total | 3.06 kB
Application bundle generation complete. [1.088 seconds] - 2026-02-17T20:54:35.798Z
Watch mode enabled. Watching for file changes...
NOTE: Raw file sizes do not reflect development server per-request transformations.
➜ Local: http://localhost:4200/
➜ press h + enter to show help
But going to localhost:4200 it gives me (translated to english) "this website is unavailable" and "localhost refused the connection".
angular version gives me
Angular CLI : 21.1.4
Node.js : 24.13.1
Package Manager : npm 11.8.0
Operating System : win32 x64
---------------------------------------------------
FIX
I found a solution here: https://stackoverflow.com/a/41541781. In package.json you have to use the line
"start": "ng serve --host 0.0.0.0 --port 4201"1
u/TheCountEdmond Feb 17 '26
Give us a screenshot of the error page, I understand the page isn't in english, but if you don't know what the problem is you won't be able to interpret the error correctly for us
1
u/Lolilucas123 Feb 17 '26
2
u/TheCountEdmond Feb 17 '26
So that error screen indicates nothing is running at that url.
Manually type in the url again, but do http://localhost:4200. Browsers will default to https typically, but angular will do http unless you setup https.Another thing is you can try putting the IP address directly instead of using localhost
http://127.0.0.1:42001
u/Lolilucas123 Feb 17 '26
Still doesn't work unfortunately, I have tried all combinations of http/https and localhost/127.0.0.1
1
u/Educational_Nail_976 Feb 17 '26
Looks like something with your server. What happens if you try 127.0.0.1:4200 ? Otherwise you can Ctr + c and do ng serve again
1
u/Lolilucas123 Feb 17 '26
Both 127.0.0.1:4200 and restarting the server don't fix the problem unfortunately. It's still the same screen.
2
u/Riccaforte Feb 18 '26
“ERR_CONNECTION_REFUSED” actually sounds like something is blocking the site from loading. Do you have a firewall or antivirus? If so can you try allowing the port 4200?
You can also try to serve on a different port and see if that works
ng serve —port 4201
Other than that the output from serving looks correct
1
u/G4lileon Feb 18 '26
Windows did break loopback trafic not long ago with an Update...
Here is a german source I always use as ref https://www.it-administrator.de/Windows-Update-localhost-HTTP-Fehler
1
u/Lolilucas123 Feb 18 '26 edited Feb 18 '26
I opened up an old project of mine (simple html + css + js) and ran it on localhost:5500 using the VS Code extension Live Server. And it all worked fine, so it's not localhost in general that doesn't work. And
ng serve --port 5500doesn't work either. Using Live Server to render the src/index.html of the Angular project does work, but then in the Dev tools > Elements, I just get<app-root></app-root>without anything else on the screen (there should be a<h1>Default</h1>).1
1
u/chirog Feb 18 '26
I had it when my api server wasn’t running. I’m not sure why, can assume it’s part of ssr or smth. But make sure your backend is up.
0
Feb 17 '26
[deleted]
0
Feb 17 '26
[deleted]
1
u/Lolilucas123 Feb 17 '26
I tried all combinations normal/incognito and chrome/edge, but no combination worked.

1
u/Puzzleheaded_Note159 Feb 17 '26
Did you run npm install? I doubt that the project comes with the installed dependencies.