after installing Nginx on a new system I have some issues when rebooting the system. Nginx is unable to start and throws this error:
`nginx: [emerg] host not found in upstream "mydomain.com" in /etc/nginx/sites-enabled/test.conf:33`
When I try to ping mydomain.com it works without any issues, I also can start the Nginx service manually. Is it possible that Nginx tries to start before the system can resolve host names?
3 thoughts on “nginx: [emerg] host not found in upstream”
Possibly DNS issue? I’d go with the IP if possible…
Have you tried adding
To your config? Where XXX. etc is the IP of a DNS server?
What distro are you using? I encountered this issue with the nginx package in Debian Stretch. It bundled a systemd service file for nginx that had an `After=network.target` dependency, so it tried to start the nginx service before the network was fully available/working. Nginx then wasn’t able to resolve the upstream domain into an IP address and failed to start.
After overriding the service file so it has `After=network-online.target` dependency instead, nginx was able to start upon reboot reliably.