Report this

What is the reason for this report?

Nginx always give me 504 error on wordpress

Posted on December 22, 2020

I got nginx 504 Gateway Time-out when trying to install plugin from wordpress dashboard.

this is the error I got from log.

2020/12/22 21:12:35 [error] 7695#0: *2188 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 116.199.102.12, server: _, request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/run/php-fpm/www.sock”, host: “68.183.225.249”, referrer: “http://68.183.225.249/wp-admin/plugin-install.php?s=TablePress&tab=search&type=term

I had trie some advice from the community by trying to incrase the execution time but not luck below is my config:

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        #root         /usr/share/nginx/html;
        root /var/www/html/wordpress;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        charset utf-8;
        gzip on;
        gzip_types text/css application/javascript text/javascript application/x-javascript  image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

        location = /favicon.ico {
                log_not_found off; access_log off;
        }


        location = /robots.txt {

                log_not_found off; access_log off; allow all;
        }

        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
        }


        location / {
                try_files $uri $uri/ /index.php?$args;
                proxy_read_timeout 240s;
        }

        location ~ \.php$ {
            fastcgi_pass unix:/run/php-fpm/www.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
                fastcgi_read_timeout 300;
                fastcgi_connect_timeout 300s;
                fastcgi_send_timeout 300s;
        }
 }

I had added inside the nginx configure file.

                fastcgi_read_timeout 300;
                fastcgi_connect_timeout 300s;
                fastcgi_send_timeout 300s;```

from php.ini change to
```max_execution_time = 300 ```

inside /etc/php-fpm.d/www.conf
changed to ```request_terminate_timeout = 300```

thanks advance if any of you can help me.


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, @stupidboy

Thanks for sharing what you’ve done so far as this will help us to offer a solution which you’ve not tried already.

May I ask if you’ve restarted the Nginx and the php-fpm service after you’ve made the changes in the configuration files?

Also is the issue occurring with the plugin in question or the issue is still persisting if you try to install other/different plguins/themes as well?

Regards, Alex

Did you ever find a solution to this problem?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.