Fix “bind() to 0.0.0.0:80 failed (98: Address already in use)” nginx error

ADVERTISEMENT

Recently, I have been buying VPSes with various companies to test setting up a light, fast and efficient Linux box to run some of my sites.

The typical install is Debian or Ubuntu, with the LNMP stack (Linux, nginx, MySQL and PHP). I chose nginx over Apache due to its much lower resource usage and the ability to handle much more parallel connections, should traffic spikes to the sites arise.

I realize that using plain old Apache with full caching (W3 Total Cache) is an option, but I prefer to let my sites run dynamically so that some specific plugins and code work properly (they won’t, if the site is cached).

With the choice of software decided, I installed the LEMP stack and tried to set up sites on the VPS box I had. One error that I came across was, “bind() to 0.0.0.0:80 failed (98: Address already in use)”, after I installed nginx, edited the necessary configuration files (nginx.conf among others) and restarted the nginx server using the /etc/init.d/nginx restart command.

ADVERTISEMENT

I tried restarting the server, and even installed the VPS from scratch, but the error did not go away. Some poking around on the server (which included examining running processes etc.) made me realize that the error was caused by Apache being bound to the 0.0.0.0:80 port. During the LEMP stack setup, I had not removed the Apache version that was bundled with the Debian/Ubuntu template installed from the VPS management page.

The solution was easy – remove the Apache software. You can do this by issuing the apt-get remove apache2 command on Debian or Ubuntu servers. Reboot the server and nginx should be humming along nicely.

You've read the post. Now what?

Click here to sign up for free email newsletter (latest articles to your inbox)

Like us on Facebook to get notified of our latest articles

Follow on Twitter to get notified of our latest articles

Recent search terms
Visitors recently searched the following terms to reach this page:
Exploit failed: Rex::AddressInUse The address is already in use, nginx: [emerg] bind() to 0 0 0 0:80 failed (98: Address already in use), 0 0 0 0:80 failed (98: Address already in use), failed: Address already in use vserver, nginx: [emerg] bind() to 188 187 188 156:443 failed (98: Address already in use)