How to fix a “could not bind to address” error in Apache

I have worked on a server recently and I came across a problem (again) that I meant to write about, and include a solution should you suffer from a similar problem. It was a Plesk server running CentOS, but this particular issue can also happen on plain LAMP stacks.

Trying to start Apache, I got the following error message:

The port number may be different depending on which port Apache is supposed to listen on (80 is the default, but depending on your system it may be something different, for example 7080). What this error is saying is that the Apache config file says the service is supposed to use a specific port, and another service is already using it. Hence, Apache can’t start or restart.

If your server has worked fine before, then it’s likely that the config file is not the problem – so don’t go messing with it unless you absolutely know what to tweak.

Let’s find out what service (or process) is listening on our port. We can do this using the lost command:

Replace the port number (80 in the above example) with your own. In this example, Apache is in fact listening but something isn’t quite right and it’s unable to restart. We can go and kill each of these processes using the following command:

Do this with every process ID (PID) from the list you get from the lsof command. As soon as they’re all dead (verify with lsof), try to restart apache once again:

This has helped me on a number of occasions 😉

  • https://wiki.apache.org/httpd/CouldNotBindToAddress

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Add your voice!