nginx + php5-fpm: Resource temporarily unavailable

Tim-Erwin asked:

I have an nginx (in a Debian docker container) with this config for a Symfony app:

location ~ ^/api/(app|app_dev|config)\.php(/|$) {
    root /var/www/backend/web/;
    fastcgi_split_path_info ^/api/(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    fastcgi_param HTTPS off;

The location is recognized correctly, the SCRIPT_FILENAME points to the correct file. However, I get

recv() not ready (11: Resource temporarily unavailable)

in the nginx debug logs whenever I make a request. nginx responds with 504 Gateway Time-out.

There are idle fpm workers which get remade the moment I kill them, seems right to me since it’s a pool. I tried using instead of the socket, but same thing. This is most likely not a question of load or memory, there’s plenty of RAM available and I’m only making a single request, CPU load is 0.0.

How can I make FPM work with nginx?

My answer:

The obvious things I see in your configuration snippet are stray / characters:

    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

Notice that in the sample configuration, this is absent.

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

You also have a stray trailing / in the root directive.

    root /var/www/backend/web/;

I expected to see:

    root /var/www/backend/web;

With your existing configuration, SCRIPT_FILENAME gets set to, e.g. /var/www/backend/web///api/config.php. This really shouldn’t matter, but it’s possible you’ve run into a scenario where it does matter.

If that doesn’t solve it, start looking at your application code.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.