Apache Error: (98) Address already in use
Occasionally your VPS or dedicated server will just not play ball.
Whenever Apache gives up the ghost it usually a case of restarting the service and within seconds your sites are back online, as if nothing happened. Great!
# service httpd restart
Most of the time, this resolves the issue. But, on occasion, apache simply doesn’t want to play. The most common issue we hear about is the Address already in use issue, which looks something like this
# service httpd restart Stopping httpd: [FAILED] Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs [FAILED]
How to resolve this apache issue
Unless apache is restarting at the time you are trying to restart manually then what we have here is a locked process. Thankfully the resolution is quite simple. We just need to find the locked process, kill it then restart apache as usual.
Let’s find the locked process id
# netstat -ltnp | grep ':80'
This will return something like this
tcp 0 0 :::80 :::* LISTEN 3826/sudo
Now we have identified the PID as 3826, we just need to kill it
# kill -9 3826
With a little luck, a simple apache start will now get everything working
# service httpd start Starting httpd: [ OK ]
If the problem persists then review the apache error log to locate the issue:
# tail -500 /var/log/httpd/error_log