Address already in use… could not bind to address… no listening sockets available

apache-2.4

I am using this server as a staging area and plan to access it via its ip addy, not a domain name. When attempting to start apache, I get the following error:

(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available


If i was suspicious of a setting, I did several searches around it and indicated so. Thanks for your help. I'll quickly fetch whatever you need.

apachectl -t -D DUMP_VHOSTS produced:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 0.0.0.0. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   localhost (/etc/apache2/sites-enabled/mydomain_staging.conf:3)

sudo netstat -lnp | grep :80 produces NOTHING

j@jjireh:/$ sudo netstat -lnp | grep :80
j@jjireh:/$ 

sudo netstat -tulpn produced: (address numbers replaced by "z")

tcp        0      0 127.0.0.1:zzzz          0.0.0.0:*               LISTEN      zzzz/mysqld     
tcp        0      0 0.0.0.0:zzzz            0.0.0.0:*               LISTEN      zzzz/sshd       
udp        0      0 0.0.0.0:123             0.0.0.0:*                           zzzz/ntpd       
udp        0      0 127.0.0.1:123           0.0.0.0:*                           3881/ntpd       
udp        0      0 0.0.0.0:123             0.0.0.0:*                           3881/ntpd       
udp6       0      0 z::z:z:z:123            :::*                                3881/ntpd       
udp6       0      0 z:z::z:z:z              :::*                                3881/ntpd       
udp6       0      0 ::1:123                 :::*                                3881/ntpd       
udp6       0      0 :::123                  :::*                                3881/ntpd 

/etc/apache2/envvars:

unset HOME # several searches around this
...

/etc/apache2/apache2.conf:

...
PidFile ${APACHE_PID_FILE} # several searches around the pid file
...

The only file in sites-available and sites-enabled is "/etc/apache2/sites-available/mydomain_staging.conf":

Listen 0.0.0.0:80  

<VirtualHost 0.0.0.0:80>
  ServerAdmin  jay@email.com
  DocumentRoot /home/j/mydomain_staging/public

  LogLevel  warn
  ErrorLog  /home/j/logs/mydomain_staging-error.log
  CustomLog /home/j/logs/mydomain_staging-access.log combined

  <Directory /home/j/mydomain_staging/public>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
  </Directory>
</VirtualHost>

Best Answer

Do not use when defining your virtual hosts, as it can cause issues from my experience.

Listen 80
<VirtualHost *:80>

would fix your issue.

Related Topic