Starting apache fails (could not bind to address 0

2019-01-20 23:56发布

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?

12条回答
一纸荒年 Trace。
2楼-- · 2019-01-21 00:25

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.

查看更多
该账号已被封号
3楼-- · 2019-01-21 00:31

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!

查看更多
孤傲高冷的网名
4楼-- · 2019-01-21 00:33

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.

查看更多
干净又极端
5楼-- · 2019-01-21 00:35

It may be skype or nginx using the port 80.

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

查看更多
聊天终结者
6楼-- · 2019-01-21 00:35

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

查看更多
萌系小妹纸
7楼-- · 2019-01-21 00:38

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
查看更多
登录 后发表回答