58

Update: Already fixed, it seems that one of VirtualHosts configurations files was wrong in sites-enabled.

I have Ubuntu 11.10

When I run the command to start apache2:

sudo /etc/init.d/apache2 start

I get the following error message:

Starting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName (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 Action 'start' failed.

I run this command in order to get the process that is using the port 80:

sudo netstat -ltnp | grep ':80'

Which returns this output:

tcp6       0      0 :::80                   :::*                    LISTEN      1176/

To know which process is I run this command:

ps -wlp1176

That returns:

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
5 D    33  1176     1  0  80   0 -     0 exit   ?        00:00:00 apache2

But if I try to kill the process:

sudo kill -9 1176

It doesn't kill it, if I run again the netstat command still appears listening and apache start fails.

Any suggestions?

rfc1484
  • 9,441
  • 16
  • 72
  • 123
  • 2
    So what is pid 1176? (`ps -wlp1176`) – geekosaur Apr 15 '12 at 07:43
  • 5 D 33 1176 1 0 80 0 - 0 exit ? 00:00:00 apache2 – rfc1484 Apr 15 '12 at 07:55
  • So, does that suggest anything to you offhand? Hint: compare to what you're trying to start. – geekosaur Apr 15 '12 at 07:57
  • It seems to me apache it's already running, but it doesn't serve pages, it doesn't stop and it doesn't start or restart. – rfc1484 Apr 15 '12 at 08:01
  • 1
    I just had a similar situation. apache2 process with a pid 1345 was taking the port 80 but did not respond to anything. `kill 1345` killed that process and then I could start a new apache2 process. – Mika Sep 03 '12 at 10:45

12 Answers12

117

Worked for me running this command:

fuser -k -n tcp 80
Blumer
  • 5,005
  • 2
  • 33
  • 47
StandDuPp
  • 1,352
  • 1
  • 11
  • 5
  • Worked for me too in Debian 4.0.4. – StandDuPp Jan 18 '13 at 16:58
  • I got this error every time restarting instance. do you know how to solve it completely? – Lam Jan 01 '15 at 02:20
  • For people not having problem with the port bind and getting a vhost syntax error, the first you have to do is look for Listen values. Look at http://wiki.apache.org/httpd/CouldNotBindToAddress at ***Conflicting Listen directives section*** – m3nda May 29 '15 at 19:03
  • 4
    This answer needs an explanation of WHY it works to be truly useful. – Aslan French Jun 20 '19 at 15:28
18

It may be skype or nginx using the port 80.

Try shutting down skype, or running: sudo /etc/init.d/nginx stop

Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
6

I had the same error, and just want to confirm that running

    sudo netstat -ltnp | grep ':80'

helped me indicate that Hiawatha webserver was in the way of Apache2.

Removing Hiawatha fixed the issue (sudo dpkg --purge hiawatha). Ubuntu 12.04.2 server.

bas-r
  • 61
  • 1
  • 1
5

I had the same problem

For me, apache was already running but it was running the wrong way.

Killing processes didnt work because a daemon kept reinstantiating it.

apachectl stop   

resolved the issue.

Philip Lowe
  • 73
  • 1
  • 5
5

use either

sudo killall httpd

or

sudo killall apache2

check if some one using the 80 port

sudo netstat -tulpn| grep :80

The restart

sudo service httpd start

then restart the server.It took me a whole day to understand the issue

enter image description here

Community
  • 1
  • 1
3

Try this, it works for me…

sudo netstat -ltnp | grep ':80'

This would return the following:

tcp6 0 0 :::80 :::* LISTEN 1047/apache2

Then

sudo kill -9 1047

Then I was able to restart Apache and everything was working fine.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Sam
  • 376
  • 3
  • 10
1

Go to device manager, select “show hidden devices” from menu/view, go to “Non-Plug and Play Driver”/HTTP, double click it to disable it (and disable or manual some services depended on it). Reboot and enjoy!

mk_yo
  • 752
  • 1
  • 12
  • 39
1

This will happen because of repeated installation of apache or port is using by another service

sudo lsof -i | grep "httpd"

You will find process id and listening port of service. Then check

cd /proc/(process id of http)

Then kill that process using command

kill -9 pid

now

sudo netstat -nltp

again kill the process

syntax:-

kill -9 pid

and now start apache

sudo ./apachectl start
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
sreeks devan
  • 13
  • 1
  • 9
1

It look like other process is using port 80.

$ netstat -anp | grep

eg. $ netstat -anp | grep 80

by above you get process name, if you want to use port then you need to stop the process or change the port

Tom Aranda
  • 5,919
  • 11
  • 35
  • 51
Satish Chauhan
  • 116
  • 1
  • 4
0

What I would do is simply check if the following is set in your /etc/apache2/sites-available/your-domain-name.com.conf

SSLEngine on 
SSLCertificateFile /your/path/to/your-domain.com.crt
SSLCertificateKeyFile /your/path/to/your-domain.com.key
SSLCACertificateFile /your/path/to/your-domain.com.ca-bundle

and there aren't any mistyped directories or anything else that would not supposed to be in your .conf file. It did the trick for me as re-starting and killing the processes did not help at all. It did not start anyway.

Mister
  • 9
  • 1
0

I fixed it by using below procedure. Run below command as root user.

root# ps aux |grep apache

It will show you Apache PID, just kill that PIDs and restart Apache Server.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
luqman
  • 11
0

You can only have listen PORTNUMBER in only one file of .conf. Do not put it in multiple files. Try it :)