# HELP - apache could not bind to address 0.0.0.0:80 SOLVED

## Moriah

I am setting up a new web server that is basicly a clone of an 8 year old machine.  The idea is to migrate to new hardware, but keep the web server basicly the same.  I emerged www-servers/apache-2.2.25 and copied the directory tree below /etc/apache2 from the old server.  I edited all the places I could find where the server domain name or ip address appeared (I grepped for them), and changed them to the temporary ip address the new server is using on my lan for testing during bring-up.

But when I try to start it, this is what I get:

```

hophni etc # /etc/init.d/apache2 status

 * status: stopped

hophni etc # ps ax | grep apache

 2750 pts/0    S+     0:00 grep --colour=auto apache

hophni etc # /etc/init.d/apache2 start

 * Starting apache2 ...

(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

 * start-stop-daemon: failed to start `/usr/sbin/apache2'                                                         [ ok ]

hophni etc # 

```

The system log file shows:

```

Jul 23 23:18:50 hophni /etc/init.d/apache2[2761]: start-stop-daemon: failed to start `/usr/sbin/apache2'

```

I know I shoudl be able to figure this out, but I am loosing patience with it; can anybody help me get this thing to start?

----------

## 666threesixes666

as root run & post output of

```

netstat -ltnp | grep ':80'

```

(to show whats running on port 80)

----------

## Moriah

Nothing has that port open:

```

hophni ~ # netstat -ltnp | grep ':80' 

hophni ~ # 

```

So, anticipating your next question, here it is without the grep:

```

hophni ~ # netstat -ltnp 

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:22              0.0.0.0:*               LISTEN      1905/sshd           

tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      1966/sshd: root@pts 

hophni ~ # 

```

 :Confused: 

----------

## 666threesixes666

no it was actually post output of this command

```

cat /etc/hosts

```

----------

## Moriah

Unfortunately, I cannot post the entire output of that file for security reasons, but I could post an excerpt, if you can tell me what you are looking for.

----------

## 666threesixes666

# IPv4 and IPv6 localhost aliases

127.0.0.1	localhost mksrv

(im looking to make sure you have an alias set)

yours should be

127.0.0.1 localhost hophni

----------

## Moriah

Here is what I think you want to see:

```

hophni ~ # grep hoph /etc/hosts

192.168.1.12            hophni          hophni.elilabs.com

hophni ~ # grep localhost /etc/hosts

127.0.0.1       localhost.localdomain   localhost

hophni ~ # grep 127 /etc/hosts

127.0.0.1       localhost.localdomain   localhost

```

So I do not seem to have what you say I need.    :Sad: 

----------

## Moriah

So I added this:

```

127.0.0.1      localhost   hophni

```

to /etc/hosts and it still does the same thing:

```

hophni ~ # ps ax | grep apache

 3355 pts/0    S+     0:00 grep --colour=auto apache

hophni ~ # /etc/init.d/apache2 status

 * status: stopped

hophni ~ # /etc/init.d/apache2 start

 * Starting apache2 ...

(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

 * start-stop-daemon: failed to start `/usr/sbin/apache2'                                                         [ ok ]

hophni ~ # 

```

----------

## 666threesixes666

(all as root)

```

echo "127.0.0.1 localhost hophni" >> /etc/hosts

```

new terminal, then try rc-service apache restart

(also whats ping -c 5 0.0.0.0 showing?)

for me mkultra@mksrv [ ~ ]$ ping -c 5 0.0.0.0

PING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.

----------

## Moriah

Not sure what you mean by:

"new terminal, then try rc-service apache restart"

But I guess you saw our posts crossed in the mail, so to speak...

Also:

```

hophni ~ # ping -c 5 0.0.0.0

PING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.015 ms

64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.010 ms

64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.012 ms

64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.028 ms

64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.028 ms

--- 0.0.0.0 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 3997ms

rtt min/avg/max/mdev = 0.010/0.018/0.028/0.009 ms

hophni ~ # 

```

----------

## 666threesixes666

```

 equery l apache -p

```

----------

## Moriah

```

hophni apache2 # equery l apache -p 

 * Searching for apache ...

[-P-] [  ] www-servers/apache-2.2.24:2

[-P-] [ ~] www-servers/apache-2.2.24-r1:2

[IP-] [  ] www-servers/apache-2.2.25:2

[-P-] [ ~] www-servers/apache-2.4.4:2

[-P-] [ ~] www-servers/apache-2.4.4-r3:2

[-P-] [ ~] www-servers/apache-2.4.6:2

hophni apache2 # 

```

----------

## Moriah

Found it!

It was in /etc/apache2/vhosts.d/ssl-vhost.conf:

```

# Listen: Allows you to bind Apache to specific IP addresses and/or

# ports, instead of the default. See also the <VirtualHost>

# directive.

#

# Change this to Listen on specific IP addresses as shown below to

# prevent Apache from glomming onto all bound IP addresses.

#

#Listen 12.34.56.78:80

#Listen 80

#Listen 192.168.1.12:80

```

The last "Listen" was not commented out.  It is now, and it now works.  

Thanks for the help!    :Very Happy: 

----------

