You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jan Kokoska <ko...@seznam.cz> on 2004/10/13 14:18:02 UTC

[users@httpd] IPv4 mixed with IPv6: Address already in use

Hi,

I run Apache 2.0.52-1 on Debian unstable with a custom 2.6.8 kernel. On
another machine with the same Apache and system packages and a custom
2.4.25-pre4 kernel, the problem is exactly the same.

I cannot specify IP to listen to using "Listen x.x.x.x:80", localhost,
catch-all, everything fails the same [0]. It appears that the IPv4
socket fails because the IPv6 socket is already bound to the port on the
same IP. 

Is this a bug? It would have to be notoriously known, so I assume
misconfiguration on my side..

Do I have to disable IPv6 altogether on my system (no I don't use it for
anything, but so far it was no trouble) to be able to bind to a single
IPv4 address? Hopefully not.

Do I have to re-compile Apache with --disable-v4-mapped to make the IPv6
socket stop bugging my IPv4? Then this would most likely be a Debian bug
as I am using a distro package.

Or alternatively, how do I tell Apache to give IPv6 a break and not ever
possibly use it? Documentation [1] says I should be able to do so by
"Listen 0.0.0.0:80", which unfortunately fails like I already described.

[0] error
---
(98)Address already in use: make_sock: could not bind to address
127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs

[1] http://httpd.apache.org/docs-2.0/bind.html

Regards,
Jan Kokoska



strace
---
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
...
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 6
bind(6, {sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6,
"::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
close(6)                                = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 6
brk(0)                                  = 0x8118000
brk(0x813a000)                          = 0x813a000
brk(0)                                  = 0x813a000
brk(0x815c000)                          = 0x815c000
setsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(6, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
setsockopt(6, SOL_TCP, TCP_NODELAY, [1], 4) = 0
bind(6, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6,
"::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
listen(6, 511)                          = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
bind(4, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr
("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
write(2, "(98)Address already in use: make"..., 78(98)Address already in
use: make_sock: could not bind to address 127.0.0.1:80
) = 78
close(4)                                = 0
write(2, "no listening sockets available, "..., 46no listening sockets
available, shutting down
) = 46
write(2, "Unable to open logs\n", 20Unable to open logs
)   = 20
close(6)                                = 0
---

Netcat has no trouble listening there:
---
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr
("127.0.0.1")}, 16) = 0
listen(3, 1)                            = 0



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] IPv4 mixed with IPv6: Address already in use

Posted by Jan Kokoska <ko...@seznam.cz>.
On Wed, 2004-10-13 at 14:28 -0400, Joshua Slive wrote:
> On Wed, 13 Oct 2004 13:18:02 +0100, Jan Kokoska <ko...@seznam.cz> wrote:
> > I cannot specify IP to listen to using "Listen x.x.x.x:80", localhost,
> > catch-all, everything fails the same [0]. It appears that the IPv4
> > socket fails because the IPv6 socket is already bound to the port on the
> > same IP.
> 
> I'm not an expert in this, but let me ask the obvious question: You

Who is, then? ;)

> are only using *one* Listen directive in httpd.conf, right?  From the
> strace output it looks like you are using
> Listen 80
> Listen 127.0.0.1:80
> which will not work since the second Listen is a subset of the first one.

Thanks! 

Debian package of Apache 2 has some lovely little file called ports.conf
which gets included at some well obfuscated point and where I am
apparently expected to put it... sure enough is has a single line
"Listen 80".

I should strace less and read my config more, thanks again ;)

Jan


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] IPv4 mixed with IPv6: Address already in use

Posted by Joshua Slive <js...@gmail.com>.
On Wed, 13 Oct 2004 13:18:02 +0100, Jan Kokoska <ko...@seznam.cz> wrote:
> I cannot specify IP to listen to using "Listen x.x.x.x:80", localhost,
> catch-all, everything fails the same [0]. It appears that the IPv4
> socket fails because the IPv6 socket is already bound to the port on the
> same IP.

I'm not an expert in this, but let me ask the obvious question: You
are only using *one* Listen directive in httpd.conf, right?  From the
strace output it looks like you are using
Listen 80
Listen 127.0.0.1:80
which will not work since the second Listen is a subset of the first one.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org