Angular-cli: Error: getaddrinfo ENOTFOUND localhost

Created on 19 Sep 2016  路  10Comments  路  Source: angular/angular-cli

  1. OS? -> Mac OSX os: darwin x64
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    => angular-cli: 1.0.0-beta.14
    => node: 6.6.0
  3. Repro steps:
    do on your code? etc.
    => Given: Install angular-cli: 1.0.0-beta.14
    When: Run "ng new my-project"
    And: I run "ng s"
    Then Get Error "getaddrinfo ENOTFOUND localhost"
  4. The log given by the failure:
    => getaddrinfo ENOTFOUND localhost
    Error: getaddrinfo ENOTFOUND localhost
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup as oncomplete
  5. ..

Most helpful comment

I can confirm adding the standard lines back for the definition of localhost on the hosts file did it form me.

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0     localhost

All 10 comments

These two links seem to indicate that there is some problem with your localhost address:

http://stackoverflow.com/questions/35757799/webpack-dev-server-cant-find-localhost
https://github.com/webpack/webpack-dev-server/issues/420

You can also see this section of the readme for a way to serve on a different address via the --host option:
https://github.com/angular/angular-cli#generating-and-serving-an-angular2-project-via-a-development-server

All started with the same error _(+ Firefox redirection from http://localhost to www.localhost.com)_ and 4h later..."still stuck"!

Long story short, it appears Ive accidently "corrupted" the /etc/hosts file when, for the anecdote, yesterday I set a new alias (who didn't worked) for my RaspberryPi IP >> without sudo <<

When Ive cat /etc/hosts the cat output was one messy line.
So I : cd /etc, sudo rm hosts, sudo nano hosts then paste and save the standard lines

I am getting below error while trying to run my angular application.....what to do to fix it?

getaddrinfo ENOTFOUND localhost
Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

@nebiljabari thanks that's work for me

I can confirm adding the standard lines back for the definition of localhost on the hosts file did it form me.

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0     localhost

It worked perfectly, Thanks :)

Worked like a charm! Had changed the hosts file while setting up a hadoop cluster and never reverted to the original. Thank you 馃憤

Worked guys awesome community!!! 馃憤 馃挴

Thanks :)

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings