Repository navigation
[Troubleshooting] PHP 8.1 site with Xdebug causes Bad Gateway error #280
Replies: 29 comments 4 replies
|
Hmm... Bad gateway errors are usually resolved by restarting nginx and PHP. Can you restart the Valet services via the menu item and let me know if that solved the issue? (You can also try "Fix My Valet", actually) If neither works, can you let me know the output of |
|
PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS) |
|
Works fine if I switch to PHP 8.3 but I run this project on PHP 8.1 in production and I would like my local and production versions match. |
|
When Xdebug is on |
|
So this is only happening with PHP 8.1, correct? And you installed xdebug via the extension manager for that PHP version? |
|
With gateway errors you can probably find more information by checking the output of Try running |
|
2024/02/22 17:58:12 [error] 94673#0: *13 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: |
Yes and I have tried installing the extension via the manager. |
|
Ah, the dreaded premature closed connection w/o much context.
|
|
Everything is up to date and I've tried |
|
Can you try the workaround I've linked? |
|
Tried Didn't work Tried deleting the sock and installing Valet again didn't work. |
|
If I disable Xdebug everything works the issue is only when Xdebug is loaded. |
|
@incon I meant this workaround, updating the Give that a try! When you installed Xdebug, was PHP 8.1 the globally linked PHP version, or not? If the workaround doesn't work I want to see if I can reproduce this issue on my own system. |
|
I noticed PGGSSENCMODE was already included. I've tried to remove everything and set everything up again Removed brew Removed items not removed by brew uninstall Removed Valet config Removed global composer Reinstall brew Launched phpmon
|
|
Switch the site to PHP 8.3 and install extension via ui, configure Xdebug and it works correctly. |
|
Issue is only when in isolation mode or not set on PHP 8.3 |
|
I'm trying to reproduce this issue and unfortunately this seems to work correctly here. I've made sure to try both PHP 8.1 linked and isolated (with PHP 8.3 as the primary version and using site isolation). As you can see: What kind of project are you trying to use with Valet? Can you try a simple site? Here's a basic test, that's the one I just did:
<?php
phpinfo();Does that work? Or are you also getting an error this way? It's always possible that your PHP script itself causes the issue. It's worth checking the nginx log too... |
|
Only when Xdeug is connected to a debuger is when I get the issue. |
|
Ah, I see. This may very well be a Xdebug or configuration issue that I'm not familiar with... from what I can tell, the app has correctly installed the extension. How are you debugging with Xdebug? What IDE? What browser? I'll see if I can't repro it on my end. |
|
Tested a phpinfo.test and it worked with debuging turn on. |
|
I just tried a blank Laravel project and it worked also. |
|
I've tried PHPStorm my normal editor and VS Code with the Xdebug plugin. |
|
Hmm... in that case I don't think I can help you any further, as it's likely an issue with that specific site or project, right? At the very least, I'm going to move this topic to Discussions, should anyone bump into a similar problem they can find this thread there under the troubleshooting section. |
|
|
|
|
I'll format my machine next week and will try again. |
|
Someone else is having similar issues on an M2 Mac https://bugs.xdebug.org/view.php?id=2167 |
|
I fixed my issue by downgrading Xdebug I found someone else with a simliar issue here but on a Linux VM https://bugs.xdebug.org/view.php?id=2246 |

Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
Current Behavior
502 Bad GatewayExpected Behavior
Turning on Xdebug makes every request return a
502 Bad GatewayerrorSteps To Reproduce
Turn on Xdebug and try to debug.
Environment
Do you have a log file (or a screenshot) or any additional information?
No response
All reactions