Last Updated: February 25, 2016
· ronanguilloux

Handling PHP's "getaddrinfo failed" errors in a Linux server when using Vagrant

A fresh linux OS running inside a vagrant box will not resolve domain names itself.

Using PHP, you'll get some "PHP php_network_getaddresses: getaddrinfo failed: No such host is known</code>" errors.

To fix it, just change your /etc/network/interfaces conf:

auto eth0
iface eth0 inet dhcp
dns-nameservers dnsserverip

Then restart the network manager :

sudo service network restart

You'll be disconnected from your previous vagrant ssh session, but that's fine, just re-log, and that's it.