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.

Bobby Iliev
Site Moderator
Site Moderator badge
July 12, 2021
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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel