Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I can't seem to get Apache to start on any port. I'm always getting the error:

apache2(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80

I checked to make sure that nothing is running on port 80 with netstat -plant|grep 80 and I even ran sudo nc -l 80 with no problems just to be certain. I thought maybe it might be a permissions thing (it shouldn't since it should be starting from an initscript), so I changed the listening port for Apache to 8080, and got the same error except on port 8080 (and nothing is running on that port either). I even tried setting ports.conf to have Listen 127.0.0.1:80 and even Listen 127.0.0.1:8080 and still more or less the same error except for showing the corresponding address and port.

I should note that I'm on Debian Unstable.

At this point, I'm at a loss for what else to check.

share|improve this question
2  
Check if SELinux or something similar is on, by runnning sestatus or getenforce. –  Ulrich Schwarz Jul 18 '13 at 4:27
    
root@debian:/home/mohsen/Downloads# netstat -atupn |egrep :80 |egrep LISTEN tcp6 0 0 :::80 :::* LISTEN 5261/apache2 –  Mohsen Pahlevanzadeh Jul 18 '13 at 5:03
    
or nmap localhost –  Mohsen Pahlevanzadeh Jul 18 '13 at 5:04
    
I don't have SELinux on this machine, so that shouldn't be an issue. That netstat command returns nothing. And nmap doesn't show port 80 as even being open. –  supercheetah Jul 18 '13 at 5:48
    
I wonder what your Apache startup script looks like? Can you post it? Let's just say for the sake of the argument that the script happened to have a bug that would start httpd twice ? –  unixhacker2010 Aug 5 '13 at 12:53

2 Answers 2

up vote 6 down vote accepted
+50

From your strace file, here is your problem:

[pid 23020] setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
[pid 23020] setsockopt(5, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
[pid 23020] setsockopt(5, SOL_IPV6, IPV6_V6ONLY, [0], 4) = 0
[pid 23020] setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
[pid 23020] bind(5, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
[pid 23020] listen(5, 511)              = 0
[pid 23020] setsockopt(7, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
[pid 23020] setsockopt(7, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
[pid 23020] setsockopt(7, SOL_IPV6, IPV6_V6ONLY, [0], 4) = 0
[pid 23020] setsockopt(7, SOL_TCP, TCP_NODELAY, [1], 4) = 0
[pid 23020] bind(7, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 EADDRINUSE (Address already in use)
[pid 23020] write(2, "(98)Address already in use: AH00"..., 82(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
) = 82

You'll notice bind is being called twice. The first time it works. The second time, it fails because the address is already in use—which it is, because it was just bound.

I have confirmed on my apache config (Apache 2.4 on Debian testing/unstable) that I can make this happen by having Listen 80 in the config twice. I suspect you've done the same, or something very similar.

share|improve this answer
    
Even without the strace the duple/multiple listen lines on same port has bitten me too. –  Manwe Aug 8 '13 at 10:35
    
This looks like IPv6 port 80 being bound twice. –  Nils Aug 9 '13 at 9:31

It looks from the error message that Apache is trying to bind using IPv6. Does your host have IPv6 enabled?

share|improve this answer
    
Welcome to Unix & Linux Stack Exchange! Please don't add comments as answers. Use actual comments when seeking clarification of any issues. –  Braiam Aug 8 '13 at 16:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.