NGINX Error: ’98: Address already in use’

KB ID 0001694

Problem

After an update, (WordPress – unrelated) yesterday, this website fell over! I rebooted the host, site was still down. I reluctantly restored to the previous evenings backup, and powered on the server. Alarmingly the site was still down!

I logged a call to my VPS provider, and attempted to troubleshoot the problem while I was waiting.

Very soon it was apparent my server appeared to be OK, but my web hosting platform (NGINX) was not running, and when I attempted to get it running this happened;

NGINX Wont Start - Address already in use

Aug 12 13:42:28 localhost nginx[2045]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 12 13:42:28 localhost nginx[2045]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 12 13:42:29 localhost nginx[2045]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 12 13:42:29 localhost nginx[2045]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 12 13:42:29 localhost nginx[2045]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 12 13:42:29 localhost nginx[2045]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 12 13:42:30 localhost nginx[2045]: nginx: [emerg] still could not bind,()
Aug 12 13:42:30 localhost systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 12 13:42:30 localhost systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 12 13:42:30 localhost systemd[1]: Failed to start A high performance web server and a reverse proxy server.

Solution

A Google search kept pointing me towards my config files for NGINX being improperly formatted for port 80, but a) NIGINX has been running fine since the server was built, and b) I update things regularly! But nevertheless I wasted an hour and half going down that road. THIS WAS A BLIND ALLEY, MY NGINX CONFIG FILES WERE FINE! 

Other posts were, (more correctly) telling me something is using that port (TCP 80 or HTTP). So, to find out what;

sudo netstat -plant | grep 80

Ubuntu whats listening on port 80

BOOM! theres my problem Apache, what’s that doing running? I’m pretty sure I (stupidly) managed to install this a while ago, when updating my PHP to the latest version. I’m guessing that this had been a ticking time bomb and my WordPress update and reboot had caused it to explode! This would also explain why a restore didn’t fix the problem!

Lets stop and disable Apache;

sudo systemctl disable apache2 && sudo systemctl stop apache2

Ubuntu Stop and Disable apache

And then (fingers crossed) start NGINX;

service nginx start
sudo service nginx status


Fix NGINX Not Starting

Site back up and running again (lesson learnt!)

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

1 Comment

  1. Thanks a lot man, helped me fix this in a few minutes 🙂

    Post a Reply

Leave a Reply to kawabooga Cancel reply

Your email address will not be published. Required fields are marked *