Jump to content

Installer: 504 Gateway Time-out


Richieboooy

Recommended Posts

Hi,

PHP has a timeout limit for script execution. You can try increasing this value to allow more time for the template installation process

In php.ini file increase the value of max_execution_time setting, for example, to 300 (5 minutes). Restart your PHP and Nginx services after making the change.

Try again after making this change.

Link to comment
Share on other sites

  On 7/13/2023 at 7:10 AM, AddWeb Solution said:

Hi,

PHP has a timeout limit for script execution. You can try increasing this value to allow more time for the template installation process

In php.ini file increase the value of max_execution_time setting, for example, to 300 (5 minutes). Restart your PHP and Nginx services after making the change.

Try again after making this change.

Expand  

I raised the max_execution_time to 300 but I still get the error.

I've looked at the phpinfo and can see that the configh was successfully loaded. 

image.png

Link to comment
Share on other sites

Hi,

Also adjust the Nginx timeout settings. Look for the proxy_read_timeout directive in your Nginx configuration file (usually located at /etc/nginx/nginx.conf or within a virtual host configuration file). Increase its value to a higher value, such as 300 (5 minutes). Save the changes and restart Nginx.

clear the cache and try again.

Link to comment
Share on other sites

  On 7/14/2023 at 7:03 AM, AddWeb Solution said:

Hi,

Also adjust the Nginx timeout settings. Look for the proxy_read_timeout directive in your Nginx configuration file (usually located at /etc/nginx/nginx.conf or within a virtual host configuration file). Increase its value to a higher value, such as 300 (5 minutes). Save the changes and restart Nginx.

clear the cache and try again.

Expand  

I followed that tutorial: https://geekrewind.com/how-to-install-prestashop-on-ubuntu-20-04-18-04-with-nginx-and-lets-encrypt/
But since php7.4 is eol I used php8.2
(maybe this helps finding/resolving the problem)

Link to comment
Share on other sites

Hi, Kindly follow below steps to check if the issue resolves,

  • Check CPU, memory, and disk usage during the installation process.
  • Monitor the Nginx access and error logs.
  • Clear cache and restart services

If this doesn't work still, then Consider creating a new clean installation of PrestaShop just in case if that installs the template files properly.

Edited by AddWeb Solution (see edit history)
Link to comment
Share on other sites

  On 7/18/2023 at 6:55 AM, AddWeb Solution said:

Hi, Kindly follow below steps to check if the issue resolves,

  • Check CPU, memory, and disk usage during the installation process.
  • Monitor the Nginx access and error logs.
  • Clear cache and restart services

If this doesn't work still, then Consider creating a new clean installation of PrestaShop just in case if that installs the template files properly.

Expand  

The cpu and cache doesn't seem to be the problem, when I look at the prestashop error log file I see this:
https://pastebin.com/WEtLfVPS

Link to comment
Share on other sites

  On 7/18/2023 at 8:50 AM, Richieboooy said:

The cpu and cache doesn't seem to be the problem, when I look at the prestashop error log file I see this:
https://pastebin.com/WEtLfVPS

Expand  

Hi,

The error message you provided indicates that the constant _PS_DO_NOT_LOAD_CONFIGURATION_ is being defined multiple times, which is causing a PHP warning during the template installation process in PrestaShop. This could be a source of the timeout issue you're experiencing.

The constant is defined in the file /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26. Verify if the constant is defined there. Also, search for any other occurrences of the constant in your PrestaShop files to check if it's defined elsewhere.

If you find multiple occurrences of the constant _PS_DO_NOT_LOAD_CONFIGURATION_, remove all but one of them.

Clear the cache and install again. This should resolve the issue. Let me know if this helps.

Link to comment
Share on other sites

  On 7/19/2023 at 5:03 AM, AddWeb Solution said:

Hi,

The error message you provided indicates that the constant _PS_DO_NOT_LOAD_CONFIGURATION_ is being defined multiple times, which is causing a PHP warning during the template installation process in PrestaShop. This could be a source of the timeout issue you're experiencing.

The constant is defined in the file /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26. Verify if the constant is defined there. Also, search for any other occurrences of the constant in your PrestaShop files to check if it's defined elsewhere.

If you find multiple occurrences of the constant _PS_DO_NOT_LOAD_CONFIGURATION_, remove all but one of them.

Clear the cache and install again. This should resolve the issue. Let me know if this helps.

Expand  

This doesn't seems to be the problem. _PS_DO_NOT_LOAD_CONFIGURATION_ only occures in two files, the first is the mentioned smarty_compile.php and the other is inside the config folder a fallback option. Removing (commenting) these lines resultet in a 500 error to  be thrown with the cause that _PS_DO_NOT_LOAD_CONFIGURATION_ isn't defined.

 

I cleard everything, logs, configuration, prestashop webserver dir and remade everything. This now appeard in the logs:

2023/07/19 09:49:28 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/"
2023/07/19 09:49:28 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/"
2023/07/19 09:49:49 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:49:49 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:49:53 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:49:53 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:50:27 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:50:27 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:50:32 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:50:32 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:51:42 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=0 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:51:42 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Constant _PS_DO_NOT_LOAD_CONFIGURATION_ already defined in /var/www/prestashop/install/controllers/http/smarty_compile.php on line 26PHP message: PHP Fatal error:  Uncaught Error: Undefined constant "_DB_PREFIX_" in /var/www/prestashop/classes/Configuration.php:175
Stack trace:
#0 /var/www/prestashop/classes/Configuration.php(229): ConfigurationCore::loadConfiguration()
#1 /var/www/prestashop/config/smarty.config.inc.php(28): ConfigurationCore::get()
#2 /var/www/prestashop/install/controllers/http/smarty_compile.php(37): require_once('...')
#3 /var/www/prestashop/install/classes/controllerHttp.php(190): require_once('...')
#4 /var/www/prestashop/install/index.php(53): InstallControllerHttp::execute()
#5 {main}
  thrown in /var/www/prestashop/classes/Configuration.php on line 175" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?compile_templates=1&bo=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:52:15 [error] 3531653#3531653: *247 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to read property "theme_name" on null in /var/www/prestashop/var/cache/prod/ContainerX0LFVLf/appAppKernelProdContainer.php on line 2906" while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?installDatabase=true&_=1689753129566 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"
2023/07/19 09:53:46 [error] 3531653#3531653: *247 upstream timed out (110: Unknown error) while reading response header from upstream, client: 129.143.170.58, server: <MyShopDomain>, request: "GET /install/index.php?installTheme=true&_=1689753129570 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock", host: "<MyShopDomain>", referrer: "https://<MyShopDomain>/install/index.php"

 

Link to comment
Share on other sites

  • 1 year later...

I've installed hundreds of prestashops with wide range of different versions and sometimes installation ends up to this "Gateway timeout".

There are only two timeout values to adjust to get rid of this error. 

php.ini:   max_execution_time  = 0   (unlimited)  after installation just change it back to 300 or any other value you need

Webserver configuration  (Apache) apache2.conf: (or any other related to your distro)  Timeout 300  (default)   change this high enough that installation goes thru, I've set this Timeout 1800  (30mins) during installation.

The real reason for the timeout might be that database is slow for some unknown reason, if freshly installed webserver / database server, maybe some nslookups or other mysterious random thing is slowing it down. By adjusting these two timeout values you should be able to install prestahop (any version).  

If having multiple versions of php &/ php-fpm installed, just make sure to adjust correct version configuration. 

Hopefully this helps someone to speed up the installation. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...