Raising Timeouts in Nginx, PHP, or HHVM

If you’ve ever tried to do a an import into WordPress, PHPMyAdmin, or anything else that may take a while processing, you may run into a timeout error. This problem can be traced back to software running your server. If you’re following our setup, you’ll be running Nginx and HHVM. If not, you might be running PHP instead.

We’re setting these timeouts to 600 seconds, or 10 minutes. Be sure to change these variables back to their default after you’re finished.


Gateway 504 error? No more!

For Nginx, we’re going to be changing the fastcgi_read_timeout variable. Depending on your setup, you may find this in different locations. If you’ve followed our tutorial, you can find it at /etc/nginx/fastcgicache.conf. You may also locate it inside /etc/nginx/nginx.conf, or possibly inside of your domain’s virtual host file in /etc/nginx/conf.d or /etc/nginx/sites-available.

fastcgi_read_timeout 600;

NGINX as a Web Proxy for Apache

If you’re using Nginx as a web proxy for Apache, congratulations on your complicated setup. You may need to alter some Apache settings as well. We can’t help you with that because we’re all about Nginx here at VisiStruct. But this will get you going on the Nginx side of things.

Inside of /etc/nginx/nginx.conf, add the following:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;


For HHVM, you simply need to edit your php.ini file, which is located at /etc/hhvm/php.ini. You’ll need to change 2 variables here.

max_execution_time = 600
max_input_time = 600


If you’re using PHP, you’ll need to edit two files. Both of these settings need to match.

First, edit your php.ini file. Its location varies depending on Linux version.

max_execution_time = 600

Then you’ll need to edit the www.conf file. Its location also varies by Linux version.

request_terminate_timeout = 600