[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 |
Beta Was this translation helpful? Give feedback.
-
PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
When Xdebug is on
|
Beta Was this translation helpful? Give feedback.
-
So this is only happening with PHP 8.1, correct? And you installed xdebug via the extension manager for that PHP version? |
Beta Was this translation helpful? Give feedback.
-
With gateway errors you can probably find more information by checking the output of Try running |
Beta Was this translation helpful? Give feedback.
-
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: |
Beta Was this translation helpful? Give feedback.
-
Yes and I have tried installing the extension via the manager. |
Beta Was this translation helpful? Give feedback.
-
Ah, the dreaded premature closed connection w/o much context.
|
Beta Was this translation helpful? Give feedback.
-
Everything is up to date and I've tried |
Beta Was this translation helpful? Give feedback.
-
Can you try the workaround I've linked? |
Beta Was this translation helpful? Give feedback.
-
Tried
Didn't work Tried deleting the sock and installing Valet again didn't work. |
Beta Was this translation helpful? Give feedback.
-
If I disable Xdebug everything works the issue is only when Xdebug is loaded. |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
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
|
Beta Was this translation helpful? Give feedback.
-
Switch the site to PHP 8.3 and install extension via ui, configure Xdebug and it works correctly. |
Beta Was this translation helpful? Give feedback.
-
Issue is only when in isolation mode or not set on PHP 8.3 |
Beta Was this translation helpful? Give feedback.
-
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... |
Beta Was this translation helpful? Give feedback.
-
Only when Xdeug is connected to a debuger is when I get the issue. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Tested a phpinfo.test and it worked with debuging turn on. |
Beta Was this translation helpful? Give feedback.
-
I just tried a blank Laravel project and it worked also. |
Beta Was this translation helpful? Give feedback.
-
I've tried PHPStorm my normal editor and VS Code with the Xdebug plugin. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'll format my machine next week and will try again. |
Beta Was this translation helpful? Give feedback.
-
Someone else is having similar issues on an M2 Mac https://bugs.xdebug.org/view.php?id=2167 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Current Behavior
502 Bad Gateway
Expected Behavior
Turning on Xdebug makes every request return a
502 Bad Gateway
errorSteps 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
Beta Was this translation helpful? Give feedback.
All reactions