4

Thanks for your help. I recently did the following:

  1. Ran sudo yum update on my ec2 instance running the Amazon Linux ami
  2. I then added a virtual host to my vhost.conf for a subdomain.
  3. While the server is still accessible, When I ran sudo httpd restart I received the following:

.

Stopping httpd:                                            [FAILED]
Starting httpd: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
                                                           [FAILED]

Also, if I run the restart command without sudo service httpd restart I receive the following message:

rm: cannot remove `/var/run/httpd/httpd.pid': Permission deniedLED]

rm: cannot remove `/var/run/httpd/httpd.pid': Permission denied
Starting httpd: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1
(13)Permission denied: AH00058: Error retrieving pid file /var/run/httpd/httpd.pid
AH00059: Remove it before continuing if it is corrupted.
                                                           [FAILED]
4
  • Looks like something's already running on port 80.
    – ceejayoz
    Oct 9, 2013 at 14:45
  • @ceejayoz, thanks for the response. I'm new to linux. How can I figure that out and then work a solution? Thanks!
    – MSchwartz
    Oct 9, 2013 at 14:48
  • @MSchwartz Seems like you are in over your head. I would recommend just rebooting the whole server in lieu of anything else. Apr 13, 2014 at 22:13
  • I fixed this by going into sudo -i then stopping and starting the service explicitly. Jun 11, 2015 at 7:08

3 Answers 3

3

From what you have provided seems that there is another process using port 80

Try to do the following:

First you need to be a root user to execute them, either you add sudo before the command, or before doing anything, switch to the user root like this:

su -root

and type the root password.

Then, proceed with:

netstat -tulpn| grep :80

The above command displays list of connections that are using port 80

Then execute the following command to kill the process that is using port 80

kill -9 <process id>

Replace process id with the process number that is shown on the screen from the previous command.

Then execute this command to start httpd process:

service httpd start
If the above did not work with you then try this

Try this i have just tested it:

for i in `lsof -i :80 | grep http | awk {' print $2'}`; do kill -9 $i; done

Then perform the restart:

service httpd restart
7
  • Thanks @MohyedeenN. After I ran netstat I got tcp 0 0 :::80 :::* LISTEN 12660/httpd. I then killed process 12660 and ran the netstat command again which then showed tcp 0 0 :::80 :::* LISTEN 13831/httpd. Is there a reason it's auto starting? After service httpd start I received this on the following comment:
    – MSchwartz
    Oct 9, 2013 at 17:05
  • Starting httpd: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1 (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs [FAILED]
    – MSchwartz
    Oct 9, 2013 at 17:05
  • @MSchwartz Please see at the end of my answer i have added a piece of code execute it then restart httpd.
    – MohyedeenN
    Oct 9, 2013 at 17:40
  • no luck, same message :/ Anything with the "AH00015: Unable to open logs" error? Also, running service httpd restart without root gives me this: rm: cannot remove '/var/run/httpd/httpd.pid': Permission deniedLED] rm: cannot remove '/var/run/httpd/httpd.pid': Permission denied Starting httpd: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1 (13)Permission denied: AH00058: Error retrieving pid file /var/run/httpd/httpd.pid AH00059: Remove it before continuing if it is corrupted. [FAILED]
    – MSchwartz
    Oct 9, 2013 at 17:48
  • 1
    @MohyedeenN sending SIGKILL as a first attempt at killing a process is a bad idea since it can't clean up.
    – sciurus
    Apr 14, 2014 at 1:59
0

Check out the user:

id

Check out the permission:

ls -l /var/run/httpd/httpd.pid

Run it to get <process id>:

netstat -tulpn| grep :80

To check out who ran the httpd:

ps -ef|grep <process id> 
0

So the answer about another process using port 80 or 443 or something is probably correct more or less, but this looks like a classic mistake which I thought I'd share. You should never ever kill -9 pidof httpd or otherwise kill apache abruptly. If you do, you will get that error until the system kills all the remaining tcp connections to/from port 80. Try netstat -alpn | grep ':80' and check if there's a bunch of connections in TCP_TIME_WAIT or something like that. You have to leave the apache server off until these ALL disappear.

Obviously you could also have a problem like having nginx or lighttpd runnning on the same machine, blocking the ports, but I bet someone killed apache. It'll take like two minutes for all those connections to go away.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .