I believe I have an error in one of my nginx configs. I have tried:

$ sudo service nginx restart
* Restarting nginx nginx [fail] 

After some googling i then tried the following:

$ sudo service nginx -t
Usage: nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}

but it only shows the list of commands. There are no messages about config errors in the nginx log or syslog. How i can get more detailed error message?


The command you are looking for is:

nginx -t

i.e. when confronted with:

$ sudo su # if necessary
$ service nginx restart
* Restarting nginx nginx [fail] 

Then use nginx -t:

$ sudo su # if necessary
$ nginx -t
nginx: [emerg] unknown directive "i" in /etc/nginx/nginx.conf:120
nginx: configuration file /etc/nginx/nginx.conf test failed
  • Nice, "don't drink and google". Need badge "drunk stupid question". – Hayate Dec 14 '14 at 2:50
  • -1 for copy pasting someone else correct answer 2 hours later while adding an error and not adding anything valuable to it. – Xavier Lucas Dec 14 '14 at 3:25
  • @AD7six As the OP shows, he's running these commands under an unprivilideged account thus requires a sudo call to avoid getting an inadequate output. And If I wanted to be pernickety about your post, there's also the direct call to init.d which is not recommanded as service discard environment variables and set the cwd to the filesystem root so the behaviour could slighly differ between both commands in a general way. He also could be using a repackaged init script using upstart instead of init.d etc. – Xavier Lucas Dec 14 '14 at 10:09
  • @AD7six Yes I consider it an error since if you get along the path of explaining to our asker which doesn't get what is the difference between directly calling a binary in its path and calling a service manager, it's likely that he will at least be confused with such an output. And out of this discussion, simply running nginx with such an option under an unpriviledged user doesn't make sense anyway. If you want to slate people's answers, then at least get your one right. – Xavier Lucas Dec 14 '14 at 14:43

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.