Wednesday, September 13, 2023

If nginx.service fails due to reason: "nginx.service failed because the control process exited":

 


If nginx.service fails due to reason: "nginx.service failed because the control process exited":

1. Restart nginx:

sudo service nginx restart

2. Run nginx -t  to see the error logs.

3. See the error log for nginx: vi /var/log/nginx/error.log

 

Logs will be something like this:

2018/08/04 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)

2018/08/04 06:17:33 [emerg] 634#0: bind() to [::]:80 failed (98: Address already in use)

2018/08/04 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)


It means port 80 is being used.


4. Install net tools if does not have by command: sudo apt-get install net-tools


5. Then see the port status i.e. With which service the port is bind.

sudo netstat -tulpn

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/apache2

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

6. Let say port 80 is bin with apache service. Then run:

sudo systemctl stop apache2

To stop the spache service.

7. Now restart the service:

sudo service nginx restart

Nginx service should be working by now.
credit: server - nginx.service failed because the control process exited - Stack Overflow



No comments:

Post a Comment