Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Address not available" error at ng serve with Angular

Tags:

angular-cli

I'm trying to compile a simple (first) Angular project on Visual Studio. I'm connected to a Hotspot. When I run ng serve I get the following error:

An unhandled exception occurred: listen EADDRNOTAVAIL: address not available 40.68.249.35:4200 See "/private/var/folders/jc/mgkz9l6x7h52sz7dcp8mrr_m0000gn/T/ng-3legRp/angular-errors.log" for further details.

[error] Error: listen EADDRNOTAVAIL: address not available 40.68.249.35:4200
at Server.setupListenHandle [as _listen2] (net.js:1296:21)
at listenInCluster (net.js:1361:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1498:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:68:8)

How can I solve this error? Currently I always use the command ng serve --host 0.0.0.0 which works...

like image 481
gozzomain Avatar asked Sep 13 '25 10:09

gozzomain


1 Answers

Go to your angular.json, Have you specified a host?

"serve": {
      ...
        "development": {
          ...
          "host": "example.com",
        },

Make sure example.com is included in your /etc/hosts file.

$ vi /etc/hosts
127.0.0.1   localhost   example.com
like image 171
raka Avatar answered Sep 17 '25 19:09

raka