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' Commented 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) Commented 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? Commented 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 Commented Feb 2, 2013 at 0:54
  • Try a reboot, yet? Every thing shows you don't have a process listening on 443. Commented 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. Commented 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). Commented Feb 2, 2013 at 3:39
  • Unfortunately, I got the same error message again. Commented 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... :( Commented Feb 2, 2013 at 0:19
  • paste the output of sudo netstat -lntup here please Commented Feb 2, 2013 at 0:26
  • Sure. I copy-pasted that output to the question body. Commented 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. Commented 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 Commented Feb 2, 2013 at 0:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.