2

I'm getting the following error message while starting apache2 server:

$ sudo /etc/init.d/apache2 start * Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information. [fail]

Here is the output of sudo netstat -lntup:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:28017           0.0.0.0:*               LISTEN      941/mongod
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      1355/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      687/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      854/cupsd
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      941/mongod
tcp6       0      0 :::22                   :::*                    LISTEN      687/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      854/cupsd
udp        0      0 0.0.0.0:22543           0.0.0.0:*                           1049/dhclient
udp        0      0 127.0.1.1:53            0.0.0.0:*                           1355/dnsmasq
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1049/dhclient
udp        0      0 0.0.0.0:46027           0.0.0.0:*                           901/avahi-daemon: r
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           901/avahi-daemon: r
udp6       0      0 :::38743                :::*                                901/avahi-daemon: r
udp6       0      0 :::27403                :::*                                1049/dhclient
udp6       0      0 :::5353                 :::*                                901/avahi-daemon: r

Anyone knows why and how it should be fixed?

Thanks!!!

5
  • instead of 'start' try 'restart' Feb 2, 2013 at 0:21
  • Your netstat isn't showing any thing on :443. Can you try sudo ss -ln and sudo lsof -inP? Also, make sure that you have freespace available. (df -h) Feb 2, 2013 at 0:46
  • "The Apache error log may have more information. [fail]" -- Have you looked in the Apache error log, by chance? Feb 2, 2013 at 0:49
  • No 443 port shown by sudo ss -ln as well. Free space is ok (more then enough). sudo lsof -inP ? does not work: sudo lsof -inP ? lsof: unknown protocol name (nP) in: -i nP lsof 4.86
    – diemacht
    Feb 2, 2013 at 0:54
  • Try a reboot, yet? Every thing shows you don't have a process listening on 443. Feb 2, 2013 at 0:56

3 Answers 3

3

Apache gives this same error message when you have two Listen directives that target the same IP/port combination. The first one succeeds without error, the second one finds that something is already listening on that port and aborts.

It's not uncommon to find these directives in different files, such as vhost files or top-level files such as ports.conf or ssl.conf.

You can find them with grep -r Listen /etc/apache2 or grep -r Listen /etc/httpd depending on whether you are using a Debian-based distro or a RedHat-based distro.

1
  • Thanks a lot! The problem was in /etc/apache2/ports.conf indeed.
    – diemacht
    Feb 2, 2013 at 12:24
2

I have had success in this situation by running the following:

/usr/bin/pkill apache2 && /etc/init.d/apache2 start

The purpose is to kill any lingering apache processes (the "pkill"), and then start apache

2
  • 1
    Apache restart/stop does not guarantee all processes get killed. Some apache processes have become non-responsive and sometimes require a non "nice" kill signal to terminate (i.e. -9).
    – mdpc
    Feb 2, 2013 at 3:39
  • Unfortunately, I got the same error message again.
    – diemacht
    Feb 2, 2013 at 12:22
1

port Apache is trying to use is already in use, use command sudo netstat -lntup and look for :443, you will find a entry. What ever is listening to port 443 stop that and try starting apache again and that should do the trick.

6
  • Strange - nobody's listening to port 443. It must be something else... :(
    – diemacht
    Feb 2, 2013 at 0:19
  • paste the output of sudo netstat -lntup here please
    – APZ
    Feb 2, 2013 at 0:26
  • Sure. I copy-pasted that output to the question body.
    – diemacht
    Feb 2, 2013 at 0:38
  • Thanks, yeah you are right nothing on port 443, did you check the apache error logs, can we see what they have to say about this.
    – APZ
    Feb 2, 2013 at 0:47
  • Last errors were from one hour ago, here they are: [Sat Feb 02 01:34:00 2013] [error] [client 127.0.0.1] access to /var/www/svn failed, reason: SSL connection required [Sat Feb 02 01:37:11 2013] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico [Sat Feb 02 01:42:09 2013] [notice] caught SIGTERM, shutting down
    – diemacht
    Feb 2, 2013 at 0:50

You must log in to answer this question.

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