5

I am working on ubuntu. I got the error messages while try to restart apache.

root@XXX:/etc/init.d# sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                              apache2: Could not reliably determine the server's fully qualified domain name,                                                               using xxx.xxx.xx.xxx for ServerName
httpd (no pid file) not running
apache2: Could not reliably determine the server's fully qualified domain name,                                                               using xxx.xxx.xx.xxx 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

I got the following message when tried netstat -pant

tcp        0   0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          32748       9950/httpd

tcp      429      0 xxx.xxx.xx.xxx:80       xxx.xxx.xx.xxx:xxxxx    CLOSE_WAIT  0          0          
user59503
  • 51
  • 1
  • 1
  • 3

5 Answers5

2

Use lsof -i :80 {check if the parameter is correct). It's listing all the application that are listening on port 80.

Also try to run apache2 {directly the executable} to check what is happening.

Nikolaidis Fotis
  • 2,032
  • 11
  • 13
1

Just kill apache pid ( i think that its 'kill 9950' )

and then try /etc/init.d/apache2 start

Arenstar
  • 3,602
  • 2
  • 25
  • 34
  • I have tried it but apache2 start shows same errors – user59503 Nov 08 '10 at 07:21
  • 1
    You need to kill what ever is running on port 80... The PID complaint is only because you are trying to stop something that hasnt written a pid.. ( not important ) Is this an aptitude install? Or a precompiled version of apache? – Arenstar Nov 08 '10 at 07:41
  • If kill does not work you can also try 'killall -9 httpd', verify using 'ps -C httpd' that process got killed and then use '/etc/init.d/apache2 start'. – Saurabh Barjatiya Nov 08 '10 at 10:15
  • 1
    After upgrade from High Sierra to Catalina in MacOs, same thing, seems like a bug. After running `sudo killall -9 httpd`, the built-in apache stop serving. `sudo apachectl stop` never stop it, but `sudo apachectl start` will start it. – KeitelDOG Dec 15 '20 at 19:05
  • 1
    Realizing that apachectl will auto-restart each time I killall httpd. The way I stopped it was to unload it from launchctl: `sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist` – KeitelDOG Dec 15 '20 at 19:17
1

From some other people's post, it's due to some applcation binds port 80, so just issue 'killall httpd' then a 'apachectl start' to make things alll normal again.

Scott Chu
  • 121
  • 2
0

use pgrep apache2 to get to get the process list

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
0

At least for me, this problem was caused by having installed nginx in the same session (and changed my mind and installed apache instead). Once I uninstalled nginx, turned off the the apache web client, started it again, and then restarted (not reload or start, restart) the service, it worked well.