0

On Archlinux, I'm running a nginx server managed by systemd. The nginx unit is enabled in systemd so it should start at boot.

But after each reboot, it fails to start with the following error:

➜  ~ journalctl -f -u nginx
-- Logs begin at Wed 2017-09-20 22:14:25 CEST. --
May 06 12:58:58 vps458278 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Start operation timed out. Terminating.
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Control process exited, code=killed, status=15/TERM
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Failed with result 'timeout'.
May 06 13:00:29 vps458278 systemd[1]: Failed to start A high performance web server and a reverse proxy server.

If I start it manually afterward with systemctl start nginx, it starts well without any issue.

Here is my nginx unit file:

➜  ~ systemctl cat nginx
# /usr/lib/systemd/system/nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target network-online.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
PrivateDevices=yes
SyslogLevel=err

ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/bin/nginx -s reload
KillMode=mixed

[Install]
WantedBy=multi-user.target

As it fails only at boot, I though one of the required units (network.target, network-online.target, nss-lookup.target) were in error but I don't see any strange stuff in their logs.

Why my nginx doesn't start at boot ? What is the best way to debug this kind of situation ?

  • Is there anything in the Nginx error log? Test the configuration using nginx -t – Richard Smith May 8 at 10:33
  • @RichardSmith nginx -t is OK, no error. No error neither in error.log. But my nginx is used as a reverse proxy. If the target of this reverse proxy is down, can it prevent nginx to start ? Eg: if nginx is a proxy to localhost:5000, but there are nothing listening on localhost:5000 ? – PierreF May 14 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.