504 Gateway Timeout

504 Gateway Timeout Error in Nginx When Installing PrestaShop

Introduction

The 504 Gateway Timeout error is a common issue that website administrators may encounter when installing applications like PrestaShop on an Nginx web server. This error indicates that the web server failed to receive a timely response from the application server, which can happen when requests take too long to process. An effective solution to this problem is adjusting the fastcgi_read_timeout and fastcgi_send_timeout parameters in the Nginx site configuration file. In this article, you will learn how to make this adjustment to resolve the 504 Gateway Timeout error and ensure that your PrestaShop installation runs smoothly.

Step 1: Locate Your Nginx Configuration Files

The Nginx configuration files are typically located in the /etc/nginx directory. The main configuration file is usually named nginx.conf, but for individual sites, you’ll be working with configuration files in the sites-available directory.

cd /etc/nginx/sites-available

Step 2: Identify Your PrestaShop Site Configuration File

You’ll need to locate the configuration file for your PrestaShop site within the sites-available directory. For example, if your site is called «example.com,» the configuration file might be named example.com.

Step 3: Edit the Configuration File

Use a text editor of your choice to open the PrestaShop site configuration file. You’ll need superuser privileges to edit this file, so you can use a command like sudo nano:

sudo nano example.com

Step 4: Adjust fastcgi_read_timeout and fastcgi_send_timeout

Inside the configuration file, look for the section related to your FastCGI settings. It may look something like this:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_read_timeout 30; 
    fastcgi_send_timeout 30; 
}

Simply, adjust the values of fastcgi_read_timeout and fastcgi_send_timeout to something like

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_read_timeout 30; 
    fastcgi_send_timeout 30; 
}

Step 5: Save and Exit

After making the changes, save the file and exit the text editor.

Step 6: Test and Reload Nginx

Before the changes take effect, it’s a good practice to test the Nginx configuration for syntax errors:

sudo nginx -t

If the test is successful, you can reload Nginx to apply the changes:

sudo systemctl reload nginx

Step 6: Verify the Error Is Resolved

Visit your PrestaShop website in a web browser to verify that the 504 Gateway Timeout error is resolved. Your site should now load correctly without timing out.

Conclusion

By adjusting the fastcgi_read_timeout and fastcgi_send_timeout parameters in your Nginx site configuration, you can resolve the 504 Gateway Timeout error that may occur during the installation or use of PrestaShop. These adjustments allow Nginx to handle longer processing times for PHP scripts, ensuring a smoother experience for your website visitors.

Artículos populares

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *