Restarting the httpd service in RHEL returns "Stopping httpd: [FAILED]" - How do I fix this?

The stop function in /etc/init.d/httpd uses the pidfile:

killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd

Possibly, the pidfile /var/run/httpd.pid is out of date or missing (could you have started httpd in the past without using the /etc/init.d script or service?). You can check that file (and its contents) with your ps -ef |grep http.

Meh, just sudo kill 20181. Then start the service up as you normally would. Then try the restart after that.

If it happens again, you probably should investigate why the pid file is getting out of whack with the process table.


You should be able to kill the HTTP processes - current connections will be disrupted, of course, and if anyone is currently sending you data (say, submitting a form) that might get lost. But generally, yeah, this will be ok. The same thing would happen with service httpd restart. You will probably have to clean up the lock file at /var/lock/subsys/httpd (delete that file).

I would then run service httpd configtest to make sure your apache config is at least loadable. Then try to start it with service httpd start

You're right that the errors about ports being in use are due to the fact that httpd is still running, and so are using those ports. Likewise, the log error too.

One other thing - there's no need to run sudo to use ps or netstat. Get into the habit of only using sudo for things that require it. It will save you trouble later, when you avoid running some destructive command with root privileges when you don't mean to.


Ran into similar on centos6 with ispconfig3 and Apache. cjc's post helped me find the answer to mine. (thanks!) It turns out the PID path in /etc/httpd/conf/httpd.conf was different than in /etc/init.d/httpd for some reason. Once I made them the same (I chose to edit httpd.conf leaving init.d script alone) then killed httpd using PID shown in ps -ef then started httpd again with /etc/init.d/httpd start & voila it works like it should. service httpd status/stop/restart/start all work as expected now too.

I suspect the http.conf file was possibly replaced from a backup of centos5 or perhaps it was edited at some point unless default was wrong although that seems unlikely.

/etc/httpd/conf/httpd.conf

Before:
PidFile run/httpd.pid

After:
PidFile run/httpd/httpd.pid

/etc/init.d/httpd gave the hint of what it was supposed to be:

# pidfile: /var/run/httpd/httpd.pid

On mine status showed Stopped even though httpd was clearly shown running in ps. stop gave an error, start gave ports some already in use error. In hindsight it makes sense now but wanted to post this up if anyone else runs into the same. stop was also giving httpd dead but subsys locked sometimes.

Example error I was getting:

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