Add name resolution dependency to systemd service

84104 asked:

How can I make a systemd service, for example nginx, start after name resolution is successful?

2017/06/30 08:39:12 [emerg] 737#0: host not found in upstream "upstream.example.com" in /etc/nginx/nginx.conf:109

I’ve attempted to add a drop-in file /etc/systemd/system/nginx.service.d/nss-depency.conf

[Unit]
After=nss-lookup.target

However this does not help, which should be obvious, as /usr/lib/systemd/system/nginx.service already has After=network.target remote-fs.target nss-lookup.target in it.


I have a similar issue with rpc-gssd.

My answer:


I think the target you’re looking for is network-online.target. This should be active only after a network connection is up and usable.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.