Question

504 Gateway timeout

We have some code that takes over 60 seconds to execute, DO is returning a 504 at exactly 60s is there any way to extend this timeout for our droplet?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
May 21, 2023

Hello,

If you’re receiving a 504 Gateway Timeout error after 60 seconds, you may need to adjust the timeout settings for your web server or proxy server (e.g., Nginx or Apache). I’ll give you an example of Nginx:

In your Nginx configuration file, you should modify the proxy_read_timeout and proxy_connect_timeout directives to extend the connection timeout for your application. For example:

  1. location / {
  2. proxy_pass http://your_backend;
  3. proxy_connect_timeout 300s;
  4. proxy_read_timeout 300s;
  5. }

Remember to restart Nginx after making changes to the configuration file.

For more information on Nginx timeouts, please visit the DigitalOcean Docs.

If you’re using a different web server, please refer to its specific documentation for adjusting timeouts.

Hope that this helps!

Bobby Iliev
Site Moderator
Site Moderator badge
May 15, 2023

Hi there,

With a Droplet, you do have full access to make any configuration changes as needed. For example, in the context of a PHP app, this is likely due to PHP’s max_execution_time setting in your php.ini file, or the timeout settings of your web server (Apache, Nginx etc.).

To fix this, you can try the following:

  1. Increase PHP’s max_execution_time: Edit your php.ini file, increase the max_execution_time to a value greater than 60. For example, to set it to 5 minutes, you’d use: max_execution_time = 300. Remember to restart your web server to apply the changes.

  2. Adjust Server Timeout Settings: If you’re using Nginx, edit your nginx.conf or applicable server block file, and increase fastcgi_read_timeout to a value higher than 60. For Apache, you can increase the Timeout directive in your httpd.conf file.

If you are not using PHP, feel free to share more details on the tech stack that you are using and I will be happy to advise you further!

Best,

Bobby

KFSys
Site Moderator
Site Moderator badge
May 15, 2023

Hey @alexborg,

There shouldn’t be any limits on that on your Droplet. What do you see in your application’s log files?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel