# apache2 won't start

## Tonglebeak

```
h4x0r lib64 # apache2

no listening sockets available, shutting down

Unable to open logs

```

I did an equery files, and chown -R apache:apache on all apache related directories. However, I still get that error above. Is there anything else I can try doing? apache 2.2.4-r10

----------

## Sadako

Are you starting it with the init script, and/or as root?

----------

## Tonglebeak

Both fail, as root.

----------

## Sadako

What port is it trying to listen on, and is there anything already listen on that port?

What does `netstat -nlp` tell you?

----------

## Tonglebeak

I'm trying to get it to listen on port 80.

```
h4x0r vhosts.d # apache2

apache2: apr_sockaddr_info_get() failed for h4x0r

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

no listening sockets available, shutting down

Unable to open logs

h4x0r vhosts.d # netstat -nip

Kernel Interface table

Iface     MTU Met   RX-OK RX-ERR RX-DRP RX-OVR   TX-OK TX-ERR TX-DRP TX-OVR Flg

lo        16436   0       8      0      0      0       8      0      0      0 LRU

ra0        1500   0   54410      0      0      0   50636      0      0      0 BMRU

```

----------

## Sadako

`netstat -nlp`, with an L, not an I.

Was this working until recently, or is this the first time you've installed and tried to run it?

Any recent update or config file changes?

Edit; Also, what does `hostname -f` return?

----------

## Tonglebeak

I've had it installed for over a year. I haven't paid attention to it to be honest, so I'm not sure what went wrong.

```
h4x0r vhosts.d # netstat -nlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      6864/mysqld

tcp        0      0 ::ffff:127.0.0.1:6880   :::*                    LISTEN      19335/java

tcp        0      0 :::6881                 :::*                    LISTEN      19335/java

tcp        0      0 ::ffff:127.0.0.1:45100  :::*                    LISTEN      19335/java

tcp        0      0 :::22                   :::*                    LISTEN      7735/sshd

udp        0      0 :::16680                :::*                                19335/java

udp        0      0 ::ffff:192.168.7.:33607 :::*                                19335/java

udp        0      0 ::ffff:192.168.7.1:8008 :::*                                19335/java

udp        0      0 :::6881                 :::*                                19335/java

udp        0      0 :::1900                 :::*                                19335/java

Active UNIX domain sockets (only servers)

Proto RefCnt Flags       Type       State         I-Node PID/Program name    Path

unix  2      [ ACC ]     STREAM     LISTENING     16509  6856/X              /tmp/.X11-unix/X0

unix  2      [ ACC ]     STREAM     LISTENING     14289  5901/hald           @/var/run/hald/dbus-DBGZ4u7IIB

unix  2      [ ACC ]     STREAM     LISTENING     11575  3878/syslog-ng      /dev/log

unix  2      [ ACC ]     STREAM     LISTENING     63239  20273/gconfd-2      /tmp/orbit-aaron/linc-4f31-0-189f3848b2ef

unix  2      [ ACC ]     STREAM     LISTENING     17387  7321/dbus-daemon    @/tmp/dbus-2UbeeiiCQ9

unix  2      [ ACC ]     STREAM     LISTENING     16652  6864/mysqld         /var/run/mysqld/mysqld.sock

unix  2      [ ACC ]     STREAM     LISTENING     14286  5901/hald           @/var/run/hald/dbus-ew3AF2SUVZ

unix  2      [ ACC ]     STREAM     LISTENING     17424  7340/kdeinit Runnin /tmp/ksocket-aaron/kdeinit__0

unix  2      [ ACC ]     STREAM     LISTENING     17426  7340/kdeinit Runnin /tmp/ksocket-aaron/kdeinit-:0

unix  2      [ ACC ]     STREAM     LISTENING     17433  7343/dcopserver [kd /tmp/.ICE-unix/dcop7343-1184620671

unix  2      [ ACC ]     STREAM     LISTENING     17524  7354/ksmserver [kde /tmp/.ICE-unix/7354

unix  2      [ ACC ]     STREAM     LISTENING     17454  7345/klauncher [kde /tmp/ksocket-aaron/klauncherGpuC2a.slave-socket

unix  2      [ ACC ]     STREAM     LISTENING     19367  7849/kdesud         /tmp/ksocket-aaron/kdesud_:0

unix  2      [ ACC ]     STREAM     LISTENING     63245  20269/firefox-bin   /tmp/orbit-aaron/linc-4f2d-0-6c461983bcaa

unix  2      [ ACC ]     STREAM     LISTENING     14066  5732/acpid          /var/run/acpid.socket

unix  2      [ ACC ]     STREAM     LISTENING     14168  5816/dbus-daemon    /var/run/dbus/system_bus_socket

unix  2      [ ACC ]     STREAM     LISTENING     16463  6780/kdm            /var/run/xdmctl/dmctl/socket

unix  2      [ ACC ]     STREAM     LISTENING     16513  6780/kdm            /var/run/xdmctl/dmctl-:0/socket

```

----------

## wizard69

i can't see an entry for apache in your netstat output. Please try netstat -tnlp which shows you all local servers that are running. Output should look like similar to this

```

web16 ~ # netstat -tnlp

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:80              0.0.0.0:*              LISTEN      8526/apache2

tcp        0      0 0.0.0.0:21              0.0.0.0:*              LISTEN      18254/proftpd: (acc

tcp        0      0 0.0.0.0:22              0.0.0.0:*              LISTEN      4659/sshd

tcp        0      0 0.0.0.0:443             0.0.0.0:*              LISTEN      8526/apache2

```

you can also check with 

```
ps aux |grep apache2
```

if you already have a running apache server. 

But looking at this error 

```
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 
```

it sounds like you have a problem with your /etc/hosts file because apache looks for the fully qualified domain name either in your hosts file or on your DNS server depending on your nsswitch.conf

----------

## Tonglebeak

Apache won't show up in netstat because it can't start.

----------

## Sven Vermeulen

Start up Apache2 through the init script. Also ensure that you have the correct Listen directives in your configuration file set. Without Listen, Apache2 won't bind and thus virtualhost definitions won't be able to get configured.

----------

## cgmd

 *Sven Vermeulen wrote:*   

> Start up Apache2 through the init script. Also ensure that you have the correct Listen directives in your configuration file set. Without Listen, Apache2 won't bind and thus virtualhost definitions won't be able to get configured.

 

How can you determine the "correct Listen directives"?

Thanks!

----------

## RinkyDinksRJ

If you're still having problems:

Apache reads the configuration in the order it happens, so you're Listen directive must be somewhere before these two includes:

```

Include /etc/apache2/modules.d/*.conf

Include /etc/apache2/vhosts.d/*.conf

```

They are at the end of the httpd.conf file.

So put your Listen directive just above them.

```

Listen *:80

## -- Excluded comments --

Include /etc/apache2/modules.d/*.conf

## -- Excluded comments --

Include /etc/apache2/vhosts.d/*.conf

```

I had this same problem when recently upgrading from 2.0.* to 2.2.*.

Good luck.

----------

## cgmd

An empty /etc/apache2/httpd.conf was, indeed, the issue. Restoring it resolved the problem.

The following lines are definitely included:

```
Include /etc/apache2/modules.d/*.conf

Include /etc/apache2/vhosts.d/*.conf 
```

Thanks!

----------

## Caleb9

I have exactly the same problem, but my httpd.conf is certainly not empty. Everything was fine with version apache-2.0.59-r5. Today I upgraded to apache-2.2.4-r12 and I get this:

```
caleb9 ~ # /etc/init.d/apache2 start

 * Starting apache2 ...

apache2: apr_sockaddr_info_get() failed for caleb9

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName        [ !! ]

```

I didn't mess up with configuration files because it was installed quite recently, so almost everything is set to default. If I add this line "Listen *:80" it changes to

```
caleb9 ~ # /etc/init.d/apache2 start

 * Starting apache2 ...

apache2: apr_sockaddr_info_get() failed for caleb9

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.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
```

The two "Include" lines are in the place. There's nothing listening on port 80 in "netstat -tnlp" output. In /etc/hosts I have only this

```
# IPv4 and IPv6 localhost aliases

127.0.0.1       localhost

::1             localhost

```

I'm using gentoo-sources-2.6.22-r5 on amd64. Plz help! :]

----------

## Tomsen

Caleb9

Add Listen 80 to your httpd.conf. It was missing in mine, and i've just updated today too.

----------

## bombcar

I have Listen 80 in my httpd.conf, but I'm still getting this error.

```
ed Sep 05 13:25:28 2007] [warn] _default_ VirtualHost overlap on port 80, the first has precedence

[Wed Sep 05 13:25:28 2007] [warn] _default_ VirtualHost overlap on port 80, the first has precedence

[Wed Sep 05 13:25:28 2007] [warn] _default_ VirtualHost overlap on port 443, the first has precedence

(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                        
```

----------

## bombcar

it was 41_mod_ssl.default-vhost.conf - I had to migrate the appropriate parts into 00_default_ssl_vhost.conf to make it work.

Note,  if you're using DEFAULT_VHOST and you put Listen:80 in httpd.conf it may be included twice (it's in 00_default_vhost.conf also.

----------

## Stokuonu

After another update I had similar error:

```
stok modules.d # /etc/init.d/apache2 start

 * Starting apache2 ...

apache2: apr_sockaddr_info_get() failed for stok

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName                                            [ !! ]

```

I added my comp name "stok" to /etc/hosts, after that apache started:

```
# IPv4 and IPv6 localhost aliases

127.0.0.1       localhost stok

::1     localhost

```

----------

## dledeaux

In my case the /etc/apache2/vhost.d/00_default_vhost.conf file was out of date after an emerge from apache 2.0 to 2.2.  I just moved the new ._00_default_vhost.conf file into use.

----------

