Nginx: Job for nginx.service failed because the control process exited

Nginx: Job for nginx.service failed because the control process exited

Try to run the following two commands:

sudo fuser -k 80/tcp
sudo fuser -k 443/tcp

Then execute
sudo service nginx restart

if it doesn’t work
Run nginx -t and if it doesn’t return anything, I would verify Nginx error log. By default, it should be located in /var/log/nginx/error.log.
You can open it with any text editor: 
sudo nano /var/log/nginx/error.log

Can you find something suspicious there?
The second log you can check is the following
sudo nano /var/log/syslog

When I had this issue, it was because my hosting provider was automatically installing Apache during a clean install. It was blocking port 80.

When I executed sudo nano /var/log/nginx/error.log I got the following as the error log:

2020/10/15 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/10/15 06:17:33 [emerg] 634#0: bind() to [::]:80 failed (98: Address already in use)
2020/10/15 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)

To fix this, you need to run the following:

yum install net-tools
sudo netstat -tulpn

When you execute the above you will get something like the following:

Proto Recv-Q Send-Q Local Address           Foreign Address         State    PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1762/httpd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1224/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1528/sendmail:acce
tcp6       0      0 :::22                   :::*                    LISTEN      1224/sshd

You can see that port 80 is blocked by httpd (Apache). This could also be port 443 if you are using SSL.

Note in my example the PID value of Apache was 1762 so I would execute 
sudo kill -2 1762

Aternatively you can execute the following:

sudo fuser -k 80/tcp
sudo fuser -k 443/tcp

Now that port 80 or 443 is clear, you can start Nginx by running the following:

sudo service nginx restart

It is also advisable to remove whatever was previously blocking port 80 & 443. This will avoid any conflict in the future. Since Apache (httpd) was blocking my ports I removed it by running the following:

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s