Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

patrykszady's avatar

nginx 504 Gateway time-out with php.ini changed - works on local homestead

Hi all,

I can't figure this out -

I'm using snappy pdf to create a large pdf doc with images. the task is done within 30secs most times, and it always works as expected unless the process takes longer than 30secs. I changed all relevant php.ini settings on my forge ( /etc/php71/fpm/php.ini) and on homestead. It works on my local homestead but my production on forge always fails if it takes longer than 30 secs to create. This makes me believe Forge is ignoring the php.ini file? I checked and my server is using /etc/php5/fpm/php.ini which is the file that has changed. I have restarted php and nginx but I don't understand what could be happening.

Thanks for any pointers!

0 likes
10 replies
Cronix's avatar

I changed all relevant php.ini settings on my forge ( /etc/php71/fpm/php.ini)

I checked and my server is using /etc/php5/fpm/php.ini

I'm confused. Are you using php5, or php7.1? Are you sure you edited the correct file?

patrykszady's avatar

I just triple checked to make sure I'm not going crazy: Changed

max_input_time = 120 max_execution_time = 300

in

/etc/php/7.1/fpm/php.ini

Cronix's avatar

And you're sure you restarted the php7.1-fpm service?

You could also just set it in your code, so it won't matter what php.ini is. This is more portable across environments as well since you don't have to alter php.ini.

set_time_limit(300);
1 like
click's avatar

Try editing the php.ini through the interface of forge it self. You can do this by clicking on 'files' at the bottom.

And as a suggestion/must do: update your local environment to PHP 7.1 so it matches your production environment. Having differences in PHP between environments is a bad idea for different reasons.

1 like
patrykszady's avatar

Thanks all, I've tried everything above. set_time_limit(300); works great on my dev homestead but of course not on my forge production. It's nice that there's the php.ini edit on the forge env … unfortunate it just displays what I already edited on the server.

Is there any nginx setting I can add to limit timeout? I'm not familiar with the settings but forge has a Edit for it. But then again, why is it working on my dev and not production if the only thing different is the location of the php.ini settings - which are the same on both.

Cronix's avatar

Are you editing "PHP FPM", or "PHP CLI" from Forge? It should be PHP FPM, but really it shouldn't matter since set_time_limit() overrides default settings. I use set_time_limit() in my code on a Forge server for a method that is a long running process, and it adheres to it.

patrykszady's avatar

Honestly, I have both changed right now in hopes one would work. Like you said, I hoped set_time_limit() would overwrite it just like it does on my dev environment with homestead.

Is there anything in nginx.conf I should be adding/changing to try?

Cronix's avatar

I'm sorry, I can't think of anything else at this point. I'd try contacting Forge Support (blue circle in lower-right hand corner when logged into Forge).

patrykszady's avatar

Thanks! I've reached out to them. Will post results asap.

Please or to participate in this conversation.