I've added a new SSL certificate to my nginx server (I've done this many times before). However, when I restart nginx, no sites are working.

When I run configtest, it says:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If nginx is running and I run nginx reload, the sites and the new ssl certificate are working.

Only when Nginx restarts, I get following:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Stopping nginx:                                            [  OK  ]
Starting nginx: 

So nothing happens after the Starting nginx. No message is written to the nginx error logs neither.

If I just use "start", often it does work.

What can I do to fix this and what could cause this?

  • Does lsof -Pni as root show anything for port 443? Are there any other previous connections showing (FIN_WAIT etc). I would think that nginx would have reuse-address socket option enabled by default (I've not yet used it); bit I've been surprised by this before. – Cameron Kerr Sep 14 '14 at 10:25
  • What is there in log file? Paste the log in your question. – Pratap Sep 14 '14 at 14:55
  • Nothing is written to the logs. The output of "lsof -Pni | grep 443" is empty, meaning there is no open connection or pending connection on that port. – K.Rens Sep 14 '14 at 15:43
  • Can you show your nginx config? Especially the part with the SSL parameters. – Melvyn Sep 15 '14 at 6:44
  • Can you confirm you ran that as root? – Cameron Kerr Sep 16 '14 at 14:23

How are you running restart? Via an init script or using service, or are you just running 'nginx restart'

To debug nginx the correct way is to add debug to the end of your error_log directive under HTTP. See http://nginx.org/en/docs/debugging_log.html

But my money is on your PID file not being cleared when restart is called.

First kill nginx and start it up again in foreground mode by adding master_process off or daemon off to your nginx.conf file.


nginx -c /etc/nginx/nginx.conf | tee ~/nginx.log

now in a different terminal run:

nginx -s restart 

And i hope you get lots of errors. You could also attach yourself to the main nginx process by running strace -fqp <pid> And try and see what its doing. (this I guess is a hail-mary approach but when you want to know exactly why the hell stuff isnt working, why not get all the information).

|improve this answer|||||

In the end I changed the encoding of the ssl file itself and then it started working.

Note: I merged the ssl files together with the > command and that didn't work properly. Downloaded the individual keys to my computer, put them together in 1 file manually and then uploaded and it started working.

|improve this answer|||||

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.