Question

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

Posted July 12, 2021 393 views
NginxDjangoPython FrameworksUbuntu 20.04

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

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.

×
Submit an Answer
1 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