DEV Community


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 localhost
3. save file and it should all work

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

Top comments (3)

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:        localhost.localdomain
Enter fullscreen mode Exit fullscreen mode

Best regards.

idevosm profile image

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

harken24 profile image

You're welcome.