# 504 Gateway Time-out errors when loading any page in local environment

**URL:** <https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570>\
**Category:** Bug Reports\
**Created:** [June 23, 2022, 3:54pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570 "2022-06-23T15:54:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 23, 2022, 3:54pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/1 "2022-06-23T15:54:24Z")

</div>

**Q: Date/Time this occurred (Provide your time zone also)**  
**A:** ~Over the last month

**Q: DevKinsta Version**  
\*\*A:\*\*2.6.0

**Q: OS Version**  
\*\*A:\*\*macOS 12.4

**Q: Docker Desktop Version**  
\*\*A:\*\*4.9.1

**Q: Were any error codes or messages observed? If so, what were they?**  
\*\*A:\*\*504 Gateway Time-out (nginx)

**Q: Detailed Description of the Problem**  
**A:**  
Had no problems with dev kinsta up until a couple of weeks ago I rebuilt my entire dev environment from scratch because of an accidental database deletion locally (when testing migrations) - my first time building an env since ~Feb 2021.

Not sure what’s happened in that time, but pages now taking 40+ seconds to load sometimes, with an average of 20+ seconds overall. It’s kind of completely unworkable and really slows down my ability to be productive. (Production is near-instant when performing similar/the same operations)

However since then, my entire local environment is bricked. It’s not that pages load slowly, they just don’t load now full stop.

I’ve tried rebuilding, upgrading everything to the latest versions, and enabling `vritiofts` in Docker, but alas no dice.

No idea what or why this is happening.

Resources allocated to docker (I have no other images installed, any other dev environments running, or any other kinsta sites installed locally)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/0/04906536323138215c84800c8da08bb5bf28bfa2.png)

(Related conversation where I was told to start a new topic for this issue) [Website Interactivity is Slow - #66 by Kevin](https://community.kinsta.com/t/website-interactivity-is-slow/293/66)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 23, 2022, 4:07pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/2 "2022-06-23T16:07:19Z")

</div>

Thanks @devstagr, I’ll be looking into this today. Does restarting the devkinsta\_fpm container or the devkinsta\_nginx containers solve the 504 error at all or is it always present now?

Also, what happens if you create a fresh WordPress site within DevKinsta? Do you have the same performance issues?

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 23, 2022, 6:58pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/3 "2022-06-23T18:58:46Z")

</div>

> [@Kevin](#):
>
> Thanks @devstagr, I’ll be looking into this today. Does restarting the devkinsta\_fpm container or the devkinsta\_nginx containers solve the 504 error at all or is it always present now?

Makes no difference, it’s eternally stuck now.

> [@Kevin](#):
>
> Also, what happens if you create a fresh WordPress site within DevKinsta? Do you have the same performance issues?

A fresh site that’s built on the existing site I’m trying to replicate? Or do you mean an entirely vanilla wordpress installation

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 23, 2022, 7:03pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/4 "2022-06-23T19:03:12Z")

</div>

I would try with a vanilla WP installation. I want to rule out issues with the site itself/make sure it’s a 504 no matter what.

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 23, 2022, 7:34pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/5 "2022-06-23T19:34:51Z")

</div>

So the vanilla installation seems to load faster, still not very fast, but certainly at a useable speed (although had to restart my machine for the installation to finish because of a random nginx error)

Main site I’m trying to work seems to load a little bit on `/wp-admin` after a long while, but navigating to `/wp-admin/edit.php` it just goes back to the 504 error once again

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 23, 2022, 8:44pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/6 "2022-06-23T20:44:25Z")

</div>

Hmm okay. I’m going to assume you didn’t add any new code or plugins that would affect wp-admin.  
Can you go to terminall and run the command `docker stats`?

Can you get a screenshot of how that looks when you load the `/wp-admin/edit.php` page? For example mine looks like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/a/a3b631177c1bb784138f6516bca6478c64b5b21e.png)

Can you also private message your php-fpm and error logs for this site? They will be in `~/DevKinsta/logs`

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 23, 2022, 9:15pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/7 "2022-06-23T21:15:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/82da57af229b51e6655db486bc6edb4c4c7b09ce.png)

DM incoming…

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 23, 2022, 9:46pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/8 "2022-06-23T21:46:58Z")

</div>

Interesting, you’re running out of PHP workers.:  
`[13-Jun-2022 10:15:41] WARNING: [pool www] server reached max_children setting (4), consider raising it`

Let’s try increasing that to something like 12 to see if you still timeout. You can do that by going to Docker Desktop and opening the terminal for the `devkinsta_fpm` container:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/6/6c43c976b3abec85e9e6e87351c3f41e050a2502.png)

Once in the terminal run these commands:

1. `sudo apt-get update`
2. `sudo apt-get install nano`
3. ` nano /etc/php/7.4/fpm/pool.d/www.conf`

Now edit the `pm.max_children` to a higher number. I would start by doubling it to 8.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/3/30d7c3c02472bce5778673dfa7ba9e5ed580ddbe.png)

After you change it to 8 and save the file you can use this command to make sure it saved correctly:  
`grep "max_children" /etc/php/7.4/fpm/pool.d/www.conf`  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/3/327163f69bcdbc9670764f67dc22bc1380d17530.png)

Now you just need to restart the container. It’s easiest to do this from Docker Desktop:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/b/b1c380eaa871c72849a6817766166b796858f3bd.png)

After all that try loading that edit page again. If it ends in a 504 again, please check the php7.4-fpm.log to see if it is returning a “max\_children” error still even with 8.

So far I feel like your site is needing more PHP workers than are available but your Mac should be able to handle more based on how much memory you have to spare.

Please let me know if you run into any issues here. I never realized how unintuitive this process was so I’ll definitely bring it up with the developers if this ends up being the issue for your site.

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 23, 2022, 11:12pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/9 "2022-06-23T23:12:15Z")

</div>

Hmmm, can’t get nano installed (vim doesn’t appear to be installed either) - is there some config option somewhere preventing external apps being installed?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/d/d440edbffa96dc73878b78a640708bc04446fe0b.png)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 23, 2022, 11:15pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/10 "2022-06-23T23:15:14Z")

</div>

No, I’m not sure what that’s about. I got the same error the first time I tried running apt-get update. It eventually went through. I’m guessing there’s some genuine issue going on with the archives. I would try again a few more times.

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 24, 2022, 1:21pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/11 "2022-06-24T13:21:36Z")

</div>

Tried a few times last night and this morning but to no avail - same error.

Is networking disabled? I can’t even run the `ping` command to test external network connections because it’s not installed/enabled inside of the fpm container

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 24, 2022, 4:10pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/12 "2022-06-24T16:10:59Z")

</div>

Yes networking is enabled. There are very few packages installed to keep the container size down. You can try an ssh command to be sure though. The general one in MyKinsta for connecting to your container should work.

Now I’m not sure why it worked for me the second time. I’m also able to install vim without issue. This might work: [https://askubuntu.com/a/1385445](https://askubuntu.com/a/1385445) The only change I made to this was using `curl -O https://...` because wget does is not installed either.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/f/f03ccd0174baa0a42a54f30c0d94a51e55d8c555.png)

I’ll also point this out to our developers

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 24, 2022, 9:29pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/13 "2022-06-24T21:29:56Z")

</div>

Hmm no dice. SSH to an external server worked first time with no issue, so probably not network related then.

Using curl on that URL I end up with  
`curl: (6) Could not resolve host: gist.githubusercontent.com`

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 25, 2022, 12:29am UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/14 "2022-06-25T00:29:29Z")

</div>

Huh, that’s weird. That one worked right away for me. Okay I’m off for the weekend but will check on this again Monday.

You can actually use the oldschool method to do this. Just using `cat` like this:

1. `cat /etc/php/7.4/fpm/pool.d/www.conf`
2. copy the output of that file to a texteditor and make your changes.
3. `cat > /etc/php/7.4/fpm/pool.d/www.conf`
4. paste your new input here; press return then ctrl/cmd+c to exit `cat’/save  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/2/241b3e74fa7cbe1e494ca3f5e5313977ea6d9419.png)

If you view the file again it should have the new values. Now restart the fpm container. My troubleshooting process was going to be increasing max\_children until the PHP loads without timing  
out.

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 27, 2022, 10:04am UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/15 "2022-06-27T10:04:31Z")

</div>

Thanks! This worked to update the config file. I’ve upgraded to 16 works, and here are the results on a few common areas

Homepage: 23s  
/wp-login.php: 1m 12s (this page is forcibly redirected  
Logging in to /wp-admin: 3m (_just_ under)  
Loading /wp-admin/edit.php: 53s

So, vast improvements given that pages actually load - but it’s still unworkably slow.

No obvious misnomers in the access or error logs.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 27, 2022, 4:13pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/16 "2022-06-27T16:13:16Z")

</div>

So it’s like PHP processing is being very inefficient. Did the fresh WordPress installation speeds improve at all? I will see if there are any more configuration tweaks that may help.

You can try using a plugin like [Query Monitor](https://kinsta.com/blog/query-monitor/) to get more details on where the slowdowns are. You can also try changing the PHP version (just remember you would have to edit the php configuration again for that specific version)

I think we have a good amount of troubleshooting info here so I’ll share all of our findings with our developers and get their advice.

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [June 30, 2022, 12:57am UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/17 "2022-06-30T00:57:36Z")

</div>

Sure - here are a few results from query monitor

User accessible dashboard (non wp-admin)

 ![Screenshot 2022-06-30 at 01.51.20](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/5/588e186017cea32396251c5b0a5b1194856c94d1.png)

wp-admin index

 ![Screenshot 2022-06-30 at 01.47.27](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/e/e407cd67540442645c0e95f249afc32149c7ffe7.png)

wp-admin posts edit page

 ![Screenshot 2022-06-30 at 01.49.25](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/4/4721b0551d38ec7286cfb2e4b359056b5e4275d6.png)

wp-admin editing an individual post

 ![Screenshot 2022-06-30 at 01.55.44](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/6/626ad2029066b5c83a625bcb98e1f36f1257fcc0.png)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [June 30, 2022, 4:32pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/18 "2022-06-30T16:32:17Z")

</div>

That’s interesting. Can you get more info on these HTTP calls? I’m wondering why each on is adding almost exactly 10 seconds each  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/e/e04a510611ae694b278644e138cdbf7065a8c283.png)

Since they are HTTP calls you should be able to see them in the Network Tab of DevConsole. What does your waterfall look like on the slowest page when sorted from slowest-quickest:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/c/cb7b2419ed515a5f9b5de0a1a5bbe739bcd99fe0.png)

---

<div class="post-metadata">

**Author:** ![devstagr](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/devstagr/32/1219_2.png) [@devstagr](https://community.kinsta.com/u/devstagr)\
**Post date:** [July 1, 2022, 10:34am UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/19 "2022-07-01T10:34:28Z")

</div>

Here you go

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/9/91ba484e0e6771793d41613a9f6dc366bc7ef701.png)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/kevin/32/808_2.png) [@Kevin](https://community.kinsta.com/u/Kevin)\
**Post date:** [July 1, 2022, 4:36pm UTC](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570/20 "2022-07-01T16:36:24Z")

</div>

Huh, admin-ajax.php loading normally is unexpected. If you go back to query monitor what are those HTTP API Calls? I thought we would be able to see them in DevConsole but I guess not. For example, when I go to edit a post, I don’t get any HTTP API Calls. Do you have a plugin running in wp-admin making slow API calls there? I’m guessing it could be related to whatever those “sync” and “retry” fetches are doing.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/0/0787d897e5557ece89f11edfdb3437a43f52316b.png)

[Next page](https://community.kinsta.com/t/504-gateway-time-out-errors-when-loading-any-page-in-local-environment/1570.md?page=2)
