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.
php -ini | grep Configuration
PHP Config can anyone tell me the path?
Thanks for such helpfull post. I was struggling for more than 2 days to resolve this problem. My problem resolved. Thanks again.
Thanks It worked like a charm!!
Added Timeout 600 to httpd.conf and it worked like magic! Thanks.
Thanks for ur information.
Thank you for this... it was definitely this setting that had to be added in, Timeout 600 in /etc/httpd/conf/httpd.conf, to prevent a gateway timeout error with an api server in my app.
This post is still useful. Added Timeout to httpd.conf and it worked. Thanks
Added Timeout 600 to httpd.conf and it worked! Thank you.
Thank you, it was very useful!
Appreciate the post.
Thank you for this post.
If you're on a shared host, you may not have full access to these properties. You can try setting them in your php file or htaccess, but that depends on your server setup. You'll have to ask them.
and in hosting ?