Increase Request Timeout on Dokku
Hey 👋,
For a project I’ve been working on recently I had to allow requests that took longer than 30s to complete.
I did my tests in local and everything worked, but when I went into my production server (using dokku): “503 Service Unavailable”
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
</head><body>
<h1>Service Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
</body></html>
That was unfortunate, but I remembered I had to deal with something similar a while ago.
I did my usual google searches, and then also some AI-questioning. But nothing seemed to work to me. And apparently I didn’t take proper notes for that in the past. So here we are.
I went back to my old projects and found something similar (increasing memory limit). Here is a step by step for my future me, or whoever needs this on the internet.
Increase Maximum Request Timeout on Dokku
In my case this was a PHP app, using https://github.com/heroku/heroku-buildpack-php.git
buildpack:
.buildpack
:
https://github.com/heroku/heroku-buildpack-php.git
This is what I needed to include in my Procfile
to customize both php-fpm
and php
settings:
Procfile
:
web: vendor/bin/heroku-php-apache2 -F fpm_custom.conf -i custom_php.ini
These parameters are kind of hidden, but you can read more in the heroku-php-apache2 codebase (should also work for heroku-php-nginx).
And these are fpm_custom.conf
and custom_php.ini
. Everything should be at the root of your project.
fpm_custom.conf
:
php_value[max_execution_time] = 60
request_terminate_timeout = 60
custom_php.ini
:
max_execution_time = 60
After that, you should’ve increased your maximum execution time from 30 seconds (default) to 60 seconds.
Beyond 60 seconds?
That was enough for me, but if you want to go beyond that. I think you might need to change also something in the internal proxy that Dokky uses (nginx). I haven’t confirmed this last part, but while reading it looked like that.
That’s all! Thanks for reading.
As usual if you liked this or found this useful drop me an email or smash the like button below :D