I have PHP-FPM
pool with such configuration blocks:
...
listen = 0.0.0.0:9000
...
pm.status_path = /status
...
I'm getting
curl: (56) Recv failure: Connection reset by peer
while trying
curl 0.0.0.0:9000/status
.
PHP-FPM
instance I try to interact with is containerized and curl
action I do from docker container.
2 Answers 2
You're trying to talk to PHP-FPM socket with HTTP; that makes no sense, PHP-FPM is a FastCGI server, not a HTTP server.
If you're not in the same network namespace, connecting to 0.0.0.0
isn't sensible at all; that's not a regular IP address, but just a way to tell a listening socket to listen on all interfaces (on Linux). It does translate to the same address of 127.0.0.1 when using it as connection address, but if the 127.0.0.1 inside a container is not usuall the same as the 127.0.0.1 outside the container, and container engines typically do not just bind a published port to the wildcard address.
-
1On Linux, 0.0.0.0 as a destination address is equivalent to localhost in this type of scenario.Stephen Kitt– Stephen Kitt2025年06月11日 01:12:42 +00:00Commented Jun 11 at 1:12
-
@StephenKitt but that's the thing, from container A to container B, without being explicitly set up to share one local network namespace, "localhost" is not the same!Marcus Müller– Marcus Müller2025年06月11日 09:04:29 +00:00Commented Jun 11 at 9:04
-
2I took the question as implying that
curl
was run in the same container as the PHP server. In any case, my comment was about "but just a way to tell a listening socket to listen on all interfaces" — that’s one of the uses of 0.0.0.0, but it’s not the only one.Stephen Kitt– Stephen Kitt2025年06月11日 09:40:37 +00:00Commented Jun 11 at 9:40 -
@StephenKitt gotcha, need to fix that answerMarcus Müller– Marcus Müller2025年06月11日 10:23:48 +00:00Commented Jun 11 at 10:23
PHP-FPM doesn't use HTTP for its communication it uses a FastCGI protocol. When you try to access it directly with curl on port 9000, you're trying to speak HTTP to a service that expects FastCGI protocol.
PHP-FPM functions as the backend interpreter for PHP, handling script execution, while the web server takes care of receiving requests and returning results to browsers.
Solutions:
Set up a web server Nginx/Apache in front of PHP-FPM
Install a FastCGI client like
Fast CGI Client
orfcgi-client
Use a PHP-FPM specific tool
Check Container Connectivity:
Make sure the containers are on the same network
Verify the port is properly exposed/published
Check if there are any firewalls between containers