DEV Community

Jozo
Jozo

Posted on

Error: getaddrinfo ENOTFOUND localhost.localdomain

Today I went to work on a project for a company I'm working (it's a web app built in Vue.js). When I encountered an error I haven't seen before.
Error: getaddrinfo ENOTFOUND localhost.localdomain

So to save you all from googling I'll show you a simple step to solve this. The problem here is that app can't find localhost as host in the /etc/host. To solve this enter in your terminal:
1. sudo vim /etc/host (you can use any editor you want I just prefer vim)
2. inside /etc/host enter 127.0.0.1 localhost
3. save file and it should all work

Pro tip:
You can do all of it with only one line sudo echo "127.0.0.1 localhost" >> /etc/host
If you get error permission denied: /etc/host simply enter in the terminal sudo chown <username> /etc/host

Top comments (3)

Collapse
 
protocod profile image
Maximilien Di Dio

Oh no that's a terrible idea ! This file must be owned by root to keep you away from security issues.

You can simply add this line to your /etc/host file:

127.0.0.1        localhost.localdomain
Enter fullscreen mode Exit fullscreen mode

Best regards.

Collapse
 
idevosm profile image
idevosm

And finally I googled it to see find it here, thanks though

Collapse
 
harken24 profile image
Jozo

You're welcome.