Skip to content

Wont bind to IPv4 if IPv6 enabled #19987

@TheRealBecks

Description

@TheRealBecks

Description

PHP-FPM can't listen to IPv4 and IPv6 simultaneously due to this old bug report from 2019: Bug #74166 IPv6 forced to be enabled

The listen parameter can be set for all IPv4 and IP6 addresses as follows:

IPv4 only

Configuration:

[www]
listen = 0.0.0.0:9000

Result:

# podman exec -it test_testcontainer_phpfpm /bin/sh
/var/www/html # netstat -tulpn
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:9000            0.0.0.0:*               LISTEN      1/php-fpm: master p

-> ✅ working as expected

IPv6 only

Configuration:

[www]
listen = [::]:9000

Result:

# podman exec -it test_testcontainer_phpfpm /bin/sh
/var/www/html # netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp6       0      0 :::9000                 :::*                    LISTEN      1/php-fpm: master p

-> ✅ working as expected

IPv4 and IPv6

Configuration:

[www]
listen = 9000

Result:

# podman exec -it test_testcontainer_phpfpm /bin/sh
/var/www/html # netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp6       0      0 :::9000                 :::*                    LISTEN      1/php-fpm: master p

-> ❌ IPv6 only, IPv4 is missing

I also tested two listen entries for IPv4 and IPv6, but the last listen parameter seems to override the first one.

This also relates to #11593

PHP Version

PHP 8.4.13 (cli) (built: Sep 25 2025 21:17:05) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies

Operating System

Official Docker container php:8.4.13-fpm-alpine3.22 with Podman instead of Docker

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions