502 Error on Local Site

Hi,

I’m having an issue where every time I try to pull from Kinsta to local with DevKinsta, it’s showing a 502 Bad Gateway error when I try to open the site. I’ve also noticed it’s not showing the screenshot of the site anymore in DevKinsta.

Any suggestions?

Hi, I’m having an issue with my site when I pull it to local. It’s giving a 502 Bad Gateway error.

I’m getting these errors in the log:

2023/03/06 18:31:57 [error] 32#32: *4 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “HEAD /?skip_cache=1 HTTP/1.1”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:32:01 [error] 32#32: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “HEAD /?skip_cache=1 HTTP/1.1”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:32:04 [error] 32#32: *10 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “HEAD /?skip_cache=1 HTTP/1.1”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:32:08 [error] 32#32: *12 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “HEAD /?skip_cache=1 HTTP/1.1”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:32:11 [error] 32#32: *14 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “HEAD /?skip_cache=1 HTTP/1.1”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:38:13 [error] 32#32: *22 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “GET / HTTP/2.0”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”
2023/03/06 18:38:13 [error] 32#32: *22 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.172.0.1, server: legaticscom.local, request: “GET /favicon.ico HTTP/2.0”, upstream: “fastcgi://172.172.0.2:9003”, host: “legaticscom.local:57916”, referrer: “https://legaticscom.local:57916/

Any advice?

Hello @VIG and welcome to DevKinsta Community!

Can you please close both Docker and DevKinsta entirely, start DevKinsta again and then send me a copy of your main.log file via DM? You can find it by clicking on the question mark icon at the bottom left corner of DevKinsta and then on Reveal log file in File Manager.
We’d like to give a look at it and help you find the culprit.

Regards,
Alessandro

Thank you for sending the file via DM @VIG.
Can you also please share what version of macOS are you using?

Regards,
Alessandro

Sure thing!

Mac OS Ventura 13.2.1 with M1 chip.

Thank you! Does your browser load a static file like the license.txt as in https://legaticscom.local:57916/license.txt

Regards,
Alessandro

Yes, this is loading the license text for me.

Okay great, can you please create a phpinfo.php page inside the root of your site and add this content to it:

<?php

phpinfo();
phpinfo(INFO_MODULES);

?>

Unfortunately, 502 it’s a pretty generic error so we need to do some troubleshooting. Let me know if you are able to see that file when loading https://legaticscom.local:57916/phpinfo.php

1 Like

Got that added and it’s loading. What do you need from that page?

Okay great, this means that PHP is working fine generally speaking. Let’s test some commands via WP CLI to see how your site responds, I feel there might be some syntax error somewhere.
Please follow the first and the second step of this guide.
Do not run the command used in step number 3, but instead use wp option get home

Does the terminal return any error or it only returns your site domain?

Regards,
Alessandro

After running those 3 commands it returns the site domain.

:thinking: does the wp-login.php page load at all? Or does it return 502 too?

Login page is a 502 as well.

Can you please run the following WP CLI command and try to access the site?

wp plugin deactivate --all

That loaded something different.

Since this theme uses Advanced Custom Fields I’m assuming that’s causing this error.

Also got this in terminal when I ran the command.

Yes looks like your theme requires advanced-custom-fields-pro to be enabled. Let’s try enabling that plugin only before setting a different theme as active if the issue persist:

wp plugin activate advanced-custom-fields-pro

Okay, after re-activating ACF Pro I’m seeing the 502 again.

It seems to be the theme. When I activate twentytwentytwo theme it comes up. How can we dig into the theme to figure out what’s causing the issue? It was working fine a couple of weeks ago.

Hello there :slight_smile:

Thank you for your reply and updates!
As I can understand, your “sage” theme requires/uses “Advanced Custom Fields” plugin and, you didn’t get 502 error when you activated “twentytwentytwo” theme because this default WP theme does not use/require that plugin (even after the plugin has been re-activated).
So far we suspect this 502 error actually seems to be from that “Advanced Custom Fields pro” plugin alone (as all other plugins have been deactivated), and this does not seem to be DevKinsta application related issue either.

This plugin does not seem to be a free plugin but a paid/premium/licensed one. Did you buy/purchase it from the plugin’s author/developer perhaps?
If that so, you may want to reach out to that plugin’s support team and see if they know something about it and how to resolve that 502 bad gateway (cause without that plugin re-enabled, you didn’t get 502 error?), as you also previously mentioned:

Okay, after re-activating ACF Pro I’m seeing the 502 again.

Also, I would check what PHP version is currently used for this local site in DevKinsta?
I’m wondering if it will work fine with different PHP version (still unsure though if this is the case or if there’s something else from that plugin itself).
Let’s say if it’s set with PHP 8.0 or PHP 8.1, may want to try to switch the PHP version for this site to 7.4 (and see if that works?).
From your DevKinsta , click that Site name from the list, then click the wrench icon on the left. After that, on that “Site configurations” page, you can click on the “PHP Version” and click the pencil icon to switch the version, and re-check your site. If it’s still showing 502 error, then I would suggest to reach out to that plugin’s support team for further assistance.

Cheers,
Agus

So changing PHP back to 7.4 seems to have fixed it. But why? I had to update to 8 to push back to kinsta and it worked fine before the last update. Also, how can I push back to Kinsta if I can’t update to PHP 8?