Question

Nginx gives an error when I run sudo systemctl restart nginx.

Hello I host a django website and set all thing then I run sudo systemctl restart nginx in my server it gives me an error that Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. then I run systemctl status nginx.service it shows me that

nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:> Active: failed (Result: exit-code) since Mon 2021-07-12 06:39:25 UTC; 1min> Docs: man:nginx(8) Process: 30855 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proc>

then I run sudo ufw allow "Nginx Full and then I run sudo ufw status its give me the result that

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
8000                       ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
Nginx HTTP                 ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
8000 (v6)                  ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)
Nginx HTTP (v6)            ALLOW       Anywhere (v6)

then I run again systemctl status nginx.service but it gives me error again and again that

nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:> Active: failed (Result: exit-code) since Mon 2021-07-12 06:39:25 UTC; 1min> Docs: man:nginx(8) Process: 30855 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proc>

So please tell me what can I do to solve this problem


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi there,

It sounds like that there might be another service already listening on that port. You could check this with the following command:

netstat -plant | grep 80

Also, what is the output of the journalctl -xe command?

If this does not provide enough information, I could suggest checking the Nginx error log:

tail -100 /var/log/nginx/error.log

Regards, Bobby

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.