Question

Nginx always give me 504 error on wordpress

Posted December 22, 2020 836 views
NginxPHPWordPressCentOS 8

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.
proxy_read_timeout 240s;
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.

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.

×
Submit an Answer
1 answer

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

  • Hi Alex , thanks for answering.

    yes I did restart nginx and php-fpm service.
    It happens to other plugin as well.

    • I’ve just tested this on a fresh droplet and I’m unable to replicate the issue.

      Can you please check the memory usage on the droplet and also monitor the performance during the plugin installation (in case the install is taking some time before it fails). You can use top or htop to monitor the resource usage.

      Also you can check for any killed processes in the messages log.

      grep -i kill /var/log/messages
      

      and

      grep -i oom /var/log/messages
      

      Hope that this helps!
      Regards,
      Alex