Reputation: 1
I was surprised because the:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
when starting Nginx, so I supposed that Nginx or other was running in the port. I've tested with:
lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 13557 www-data 8u IPv4 100729 0t0 TCP *:http (LISTEN)
nginx 13558 www-data 8u IPv4 100729 0t0 TCP *:http (LISTEN)
so yes, Nginx was working and in fact web pages are running. All perfect but...not!
How can be possible this?
service nginx status
[FAIL] nginx is not running ... failed!
Not running? But I can't start any other instance because it's running! What's happening?
The same when restarting:
service nginx restart
Restarting nginx: Enter PEM pass phrase:
Enter PEM pass phrase:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Thanks in advance.
Upvotes: 0
Views: 1552
Reputation: 786
Check if nginx is running with:
ps aux | grep nginx
if nginx process exists, then it's running for sure. What you verified with lsof only proves that 80 port is occupied by certain process (for instance, apache httpd, or some other http servers). If nginx process is not running and yet 80 port is being used, which also explains why you can't start your nginx. In this scenario, you need to lookup in your process list to see which web server is already running. Kill it and restart nginx, it should be then working fine.
Upvotes: 4