I'm using nginx mainly as an http(s) proxy, for this I need to provision some domain names, which nginx tries to resolve (DNS) at startup.

If I start nginx manually (using systemctl start) after the pc has completely booted, this works just fine, however when just enabling it for autostart I get the following issue (mydomainname is something that normally would actually resolve, I just hid it here):

$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2016-02-13 10:41:47 CET; 45min ago
  Process: 844 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Feb 13 10:41:47 mysystem systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 13 10:41:47 mysystem nginx[844]: nginx: [emerg] host not found in upstream "mydomainname" in /etc/nginx/sites-enabled/default:8
Feb 13 10:41:47 mysystem nginx[844]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 13 10:41:47 mysystem systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 13 10:41:47 mysystem systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 13 10:41:47 mysystem systemd[1]: nginx.service: Unit entered failed state.
Feb 13 10:41:47 mysystem systemd[1]: nginx.service: Failed with result 'exit-code'.

I am using ubuntu 15.10, I use the standard nginx package. What I already tried:

  • Change After in systemd script from network.target to network-online.target
  • Add nss-lookup.target to the After
  • Put it to all three: network.target network-online.target nss-lookup.target

But it keeps giving that error.

share|improve this question

After some digging around I found out that the component enabling systemd to wait for the network manager to complete is not enabled by default. After enabling this as follows, it works perfectly:

sudo systemctl enable NetworkManager-wait-online.service
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.