DEV Community

Cover image for Error: GetAddrInfo ENOTFOUND localhost
Davide de Paolis
Davide de Paolis

Posted on

Error: GetAddrInfo ENOTFOUND localhost

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)