DEV Community

Jozo
Jozo

Posted on

2 1

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay