loading...
Cover image for Error: GetAddrInfo ENOTFOUND localhost

Error: GetAddrInfo ENOTFOUND localhost

dvddpl profile image Davide de Paolis ・1 min read

I am dropping this here as a reminder for my future self and for anyone that might encounter this weird error.

At work we are using nodejs and serverless framework to build a backend application.

To test it we just run it locally with

sls offline start --port 3001

Today, a colleague who was working remotely asked me if I could run the app locally because he was getting this error:
Error GetAddrInfo ENOTFOUND localhost

The info we found googling were mostly related to Webpack or Angular, which we are not using but had in common some problems in the configuration of etc/hosts.

Confronting that configuration on my workstation and his laptop at home, I had:

where his contained info about OpenVN Client SSL but nothing about localhost. Probably when he configured the VPN to work remotely he overwrote the previous content, he added to his file this one line:

127.0.0.1 localhost

and everything started to work.

Additional tip:

  • To edit the file: go to home directory ( cd ~ ) and open vim sudo vi /etc/hosts then press I and start editing the file.

exiting vim

  • To save and exit vim: press ESC then :wq or :q! if you just want to exit without saving. More cheatsheets here

Posted on May 11 by:

dvddpl profile

Davide de Paolis

@dvddpl

Sport addicted, productivity obsessed, avid learner, travel enthusiast, expat, 2 kids. πŸ‚βœˆπŸšžπŸŒπŸ“·πŸ–₯πŸ€˜πŸ‘¨β€πŸ‘©β€πŸ‘¦β€πŸ‘¦πŸš€ (Opinions are my own)

Discussion

markdown guide