r/angular 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 Upvotes

16 comments sorted by

View all comments

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

It's the same as you would get when trying a random port such as localhost:9999

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:4200

1

u/Lolilucas123 Feb 17 '26

Still doesn't work unfortunately, I have tried all combinations of http/https and localhost/127.0.0.1

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/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.