Check the syntax of Nginx’s configuration file

Posted 2 years ago

I had a problem where I couldn’t restart a server powered by Nginx after making a lot of startup configuration changes.

The error I had was

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

Simply run this command

sudo nginx -t -c /etc/nginx/nginx.conf

I was returned

nginx: [emerg] a duplicate default server for in /etc/nginx/sites-enabled/test:17
nginx: configuration file /etc/nginx/nginx.conf test failed