Apache server not listening on IPv4 but listening on IPv6
assiduus@localhost:~/httpd-2.4.34$ ./configure --help | grep IPv6
--enable-v4-mapped Allow IPv6 sockets to handle IPv4 connections
assiduus@localhost:~/httpd-2.4.34$
This is enabled by default when you compile Apache httpd from source. If you used your distribution binary package then apparently this option is enabled.
Related videos on Youtube
amol
Updated on September 18, 2022Comments
-
amol over 1 year
We are facing one weird problem on one of our RHEL apache server.
Actually, it is not listening on port 80 from remote hosts. When we locally browse
http://localhost
it is opening default page. When we checked listening port throughnetstat
, we found that onlytcp6
interface was listening at:::80
. And there was no entry fortcp
, and that entry should be present there liketcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
I have tried searching many forums for this issue, but none of the solution suggested worked. In
httpd.conf
, we changeListen 80
toListen 0.0.0.0:80
andListen 127.0.0.0:80
but it did not open 80 port to access from remote hosts. IPtables is disabled from the beginning.How can we set the server to listen on IPv4?
-
Johan Myréen over 6 yearsYou could try to set
net.ipv6.bindv6only=0
in/etc/sysctl.conf
and then runsudo sysctl -p
. This makes the socket listen on both IPv4 and IPv6. -
Rui F Ribeiro over 6 years
tcp6 0 0 :::80
Is indicative of the server listening both in IPv4 and IPv6. You can put it back atListen 80
. How is the vhost/default vhost configured? -
Raman Sailopal over 6 yearsCheck you apache logs for any issues relating to listening on the ip4 address,
-
amol over 6 years@JohanMyréen I tried using your suggestion, but the result is unchanged. Raman, there are no specific logs generated related to IPv4. Surprisingly, SSH server is running and it is listening on IPv4 and IPv6 port 22. When tried with Listen 0.0.0.0:80 in httpd.conf, the netstat showed tcp entry as tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN but still the port 80 was not accessible from remote hosts.
-
Johan Myréen over 6 yearsTry if the connection succeeds from the local host using the non-localhost IP address. If it is ok, and nothing else that you have tried works, I suspect the problem lies elsewhere (firrewall, etc.) Listening on :::80 should not be a problem, since normally a socket listening on IPv6 also accepts IPv4 connections, unless disabled with
bindv6only=1
. -
amol over 6 yearsJohan, I appreciate your suggestions. I am able to open localhost in the same system. But when I access the server from remote host in the same network, it does not give any response. I have completely removed httpd package with all conf files and reinstalled it but the issue is still there. IPTables is completely out of frame as we have disabled it from beginning.
-
Johan Myréen over 6 yearsBut can you connect in the same system, not using
localhost
(127.0.0.1
or::1
) but the IP address of the server? Let's say the server IP address is10.2.3.4
, try URLhttp://10.2.3.4/
.
-