I just started with Local. Installed Local, VS Code and the Xdebug + VS Code extension. Installed a test version of a WordPress website.
This is working all right, but when I wait longer than 60 seconds while “sitting on a breakpoint” in VS Code, my browser produces a 504 gateway timeout error. To get the website to “continue”, it has to be reloaded.
In my old setup (with DesktopServer and VS Code)) this did not happen, so I guess I should be able to change this with some setting somewhere, but I cannot find it.
Does this happen for all sites in Local, or just one in particular?
I have only one site at this time.
Are you able to create a new, plain WordPress site in Local and access it in a Browser?
- Start WordPress website, installed on Local
- Open a page from this website in a browser
- Open the website in VS Code
- Set a breakpoint in, for example my theme’s functions.php file
- Reload the webpage in the browser, causing functions.php to be run
- VS Code shows that the breakpoint is hit
- Don’t leave the breakpoint but wait 60 seconds: the browser produces a 504 gateway timeout error
There is no recovery from this status, other than starting all over again (reload the web page). For step-wise debugging this is quite inconvenient.
- Which version of Local is being used?
Local 5.10.3+5332 (system setup), but it also happened on 5.10.1, a few days ago
Extension Xdebug + VS Code 1.0.6
VS Code 1.55.0 (system setup)
Site settings: Apache 2.4, PHP 7.4.1, MySQL 8.0.16
Browser Firefox Developer Edition 88
local-lightning.log (140.1 KB)
Ok, I think I have found something that “narrows down” the problem. It only occurs when using Apache, not with nginx.
Configuration files in
fastcgi_read_timeout settings of 1800s (nginx.conf) and 1200s (site.conf).
After I changed the website in Local from Apache to nginx (which just worked, amazing!), the 504 Gateway Timeout occurred after 1200 seconds instead of 60. Furthermore, the timeout was caught by Local, resulting in a decent message from Local (… If the error persists, check the Local Router Logs in Local by going to Help » Reveal Local Router’s Logs …).
Unfortunately the “live” version of the website is running at a service provider that only provides Apache, not nginx, and the website includes some site-specific .htaccess files. So testing on nginx instead of Apache is not a very good idea.
So the problem remains, I could not (yet) find a similar setting for Apache…
I found that I can get rid of the 504 Gateway Timeout error messages while debugging, by adding to the file
TimeOut 3600 (or some other large number of seconds)
This is of course more of a ‘hack’ than a decent solution. The change survives a Local restart and a computer reboot, but I guess it may get lost when installing a Local update, for example.
5xx errors, I always like to refresh in my mind what they specifically mean.
504 Gateway Timeout
The HyperText Transfer Protocol (HTTP) 504 Gateway Timeout server error response code indicates that the server, while acting as a gateway or proxy, did not get a response in time from the upstream server that it needed in order to complete the request.
So basically, this is telling us that something is tired of waiting for a response and gives up by sending a
You’ve verified that’s the case by increasing the timeout.
I was able to replicate on my Mac, which means that it isn’t specific to Windows. From the googling I did, it doesn’t seem like the timeout setting is something that can just be toggled off, so I would imagine that if you didn’t experience this in Desktop server, it’s probably because they just have a very high timeout set as the default.
Either way, I bet there isn’t an easy fix, and the quickest thing to do is to set a high timeout for any of these sites that you need a high timeout on.
Thank you for your reply and for looking into this.
The default timeout value should be good enough. This is NOT about a problem that I need a long timeout for a specific site.
This problem is about debugging of scripts on the server. While in PhpStorm or VS Code (or some similar app), when you have set a breakpoint in a script and ran that script till the breakpoint is reached, the execution of that script stops. Then, while you are investigating the value of variables, maybe execute some command, correct some code, set another breakpoint etc., a gateway timeout will occur when you are not quick enough continuing the script execution (default 60 sec, see this nginx documentation and this Apache documentation).
This applies to anybody using Local and doing PHP debugging for any website.
For nginx in Local you already have taken this into account by changing the default timeout value to 1200 sec. For Apache on Local this is not (yet) the case; there it is still the default 60 sec.
I have found out that this can be done and it is not complicated at all, but the location in the software where I made the change to specify the higher timeout value myself is clearly not the best and you should know better how to do this generically and future-proof.
It would really be nice if you could change this for Apache, like you did for nginx.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.