Disabling listening IPv6 in config file of Apache2 server

By default, Apache will listen on all IPs, both IPv6 and IPv4.
This is controlled by the Listen directive:

root@localhost ~ # egrep -r Listen /etc/apache2
...
/etc/apache2/ports.conf:Listen 80
...
root@localhost ~ # 

To turn off IPv6 in Apache, just change the Listen directive to:

Listen 0.0.0.0:80

This will limit Apache to listening only to IPv4 connections. Repeat this for port 443 if you want to stop Apache from listening for HTTPS on IPv6.

Scroll to top