Nginx – Temporary Failure in name resolution. Ubuntu 18.04

haproxynginxubuntu-18.04

I am working on some new vps for an application we use. Which are running on Ubuntu 18.04.2 behind a seperate haproxy vps which load balances between two front ends running the same code and app.

The app uses the google directions api to get distance of users from a specific place. The full error is

Message: 
file_get_contents(https://maps.googleapis.com/maps/api/directions/json?origin=[ORIGIN]&destination=[DESTINATION]&key=[KEY]): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

I know the url works as I can go to it on a browser and it works on the current app which is running on a different server.

I have tried a lot of the suggestions on here. I have tried changing dns servers in

 /etc/network/interfaces
 /etc/resolv.conf 
 /etc/systemd/resolved.conf

Also tried changing server name in

hostnamectl 
/etc/hosts

restarting nginx 
rebooting server

I can ping google and maps.googleapis.com and get responses.

trying wget responded with

Resolving maps.googleapis.com (maps.googleapis.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘maps.googleapis.com’

Best Answer

Did you try wget https://maps.googleapis.com/maps/api/directions/json?origin=[ORIGIN]&destination=[DESTINATION]&key=[KEY] ? If this works, too, it's possibly just your application (server) that is not configured to use the systems proxy settings. Did you check that already?