PHP and Apache 504 Gateway Timeout Troubleshooting and Solutions
Jan 29, 2015Web DevelopmentComments (14)
If you're experiencing a 504 Gateway Timout on your long PHP scripts, despite having lengthy execution times in php.ini, here are some things you should check.
If you haven't yet, make sure both max_execution_time and max_input_time in your php.ini file are set to a sufficient number of seconds. For example:
If you have PHP set correctly, it may be Apache's config that is timing out. The setting that controls its timeout is not always present in httpd.conf by default, so you may have to add it.
Open up httpd.conf and look for the setting Timeout. If it doesn't exist, add it on its own line and set it to a sufficient number of seconds. For example:
If you're experiencing the timeout in PHPMyAdmin, keep in mind that it has its own execution time limit ExecTimeLimit. Open up config.inc.php and if it doesn't exist, add a config option with a sufficient number of seconds like this:
If that config option already exists, edit it to the desired number of seconds.
PHP Config
If you haven't yet, make sure both max_execution_time and max_input_time in your php.ini file are set to a sufficient number of seconds. For example:
max_execution_time = 600
max_input_time = 600
Apache Config
If you have PHP set correctly, it may be Apache's config that is timing out. The setting that controls its timeout is not always present in httpd.conf by default, so you may have to add it.
Open up httpd.conf and look for the setting Timeout. If it doesn't exist, add it on its own line and set it to a sufficient number of seconds. For example:
Timeout 600
PHPMyAdmin
If you're experiencing the timeout in PHPMyAdmin, keep in mind that it has its own execution time limit ExecTimeLimit. Open up config.inc.php and if it doesn't exist, add a config option with a sufficient number of seconds like this:
$cfg['ExecTimeLimit'] = 600;
If that config option already exists, edit it to the desired number of seconds.