I've just installed nginx on Debian Jessie, and I can't start it:

$ sudo /etc/init.d/nginx start
[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Sat 2015-08-29 17:54:15 EDT; 6s ago
  Process: 16824 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 8407 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 691 (code=exited, status=0/SUCCESS)

I've run netstat -a -b and looked through the list but I can't see anything else running on port 80.

How can I debug this?

UPDATE: tried sudo nginx -t to see if it produced anything helpful:

$ sudo nginx -t
nginx: [emerg] BIO_new_file("/etc/nginx/certificates/certificate-178724.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/certificates/certificate-123353.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
  • I just noticed that there was an old conf file in /etc/nginx/sites-available and I think it was something to do with that - I've deleted it and it works. It would be nice to know how to have figured this out from logs though! – Richard Aug 29 '15 at 22:13

The output of nginx -t tells you everything you need to know -- it couldn't read a certificate file your configuration referenced. Grep around in /etc/nginx for mentions of that file, and you would have found the file it was referenced in.

Amusingly, in the terrible, dark days before systemd, the nginx init script would have given you that error straight up. Chalk up another usability win for the new world order!

  • And in the modern days on any reasonable (read: not Debian-based) systemd system, systemd already runs nginx -t for you as part of startup. – Michael Hampton Aug 29 '15 at 22:32
  • So did Debian in the pre-systemd days. – womble Aug 30 '15 at 2:40

Your Answer

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

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