Closed ryangjchandler closed 2 years ago
"502 Bad Gateway" typically means that the "gateway process making the request" couldn't complete. Often this is php-fpm which is failing to respond, or is encountering an error. Usually the cause of the failure is in the php-fpm logs, or sometimes in the nginx logs. Sometimes the cause is a dns lookup failure ... but if normal web-surfing is fine, then if the dns lookup is failing for one particular destination it's likely that you've got a local dns config override issue such as something you added to /etc/hosts
You didn't mention it, but I suppose if your issue is related to Laravel DebugBar then this proposed change might benefit you: https://github.com/laravel/valet/pull/1079/files ... You'd have to apply it to your existing config and restart. If it resolves your situation, please post to that PR's discussion saying so. If it makes no difference then it's unrelated.
I have already tried the fastcgi
params inside of the sites config unfortunately and had no luck.
The php-fpm
log didn't show anything unusual (it was completely empty), the nginx.log
file did contain the following line:
2021/08/12 21:52:45 [error] 280#0: *11 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: claims.test, request: "GET /search HTTP/2.0", upstream: "fastcgi://unix:/Users/ryan/.config/valet/valet.sock:", host: "claims.test"
I've tried restarting both Nginx and PHP via valet restart
, completely uninstalled Valet and reinstalled with no luck.
Also the request isn't failing for one particular destination. Any request to an external site, e.g. https://jsonplaceholder.typicode.com/
will fail, as well as any request from one Valet site to another.
Quick suggestion to try:
https://github.com/laravel/valet/issues/968#issuecomment-656454281
This adds a specific dns resolver to dnsmasq for non local sites. You can put whatever source you want.
Still no luck with one, or both, of those files inside of the dnsmasq.d
folder.
@drbyte Still having issues with this, is there anything else I can try? I'm unable to use Valet with any site that uses Stripe, S3, anything.
Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel to open up a new issue if you're still experiencing this.
Thanks @driesvints. The problem was actually the libvips extension interfering with the requests. Disabling fixed it all.
@ryangjchandler did you ever figure out why vips is making this happen? Recently upgraded from php7.4 to 8.0 and this happened, but disabling the extension cures the issue...
Just came across this issue. I still had ext-vips
installed, even tho v2 of jcupitt/vips
uses FFI now and doesn't actually need ext-vips
anymore, so removing the extension fixes the issue.
today i was trying to install/ using vips and also discovered it breaks my pages. no matter if i use php8.0. or 8.2.4. as soon as i enable vips extension and restart php service, all pages are broken. but i wonder if someone managed to get all running successfully? i mean vips should be faster than imagick. i am curious to give it try.
Clear description of your problem
When making requests to an external service, e.g. an API all request result in a 502 Bad Gateway error.
Sites run fine otherwise, it's only when making external requests. E.g. Stripe requests fail, even requests from one local site to another.
Expected behavior
Requests should not fail.
Steps to Reproduce
Really not sure on the reproduction steps. It started happening out of the blue.
Diagnosis
sw_vers
valet --version
cat ~/.config/valet/config.json
cat ~/.composer/composer.json
composer global diagnose
composer global outdated
ls -al /etc/sudoers.d/
brew config
brew services list
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
brew outdated
brew tap
php -v
which -a php
php --ini
nginx -v
curl --version
php --ri curl
~/.composer/vendor/laravel/valet/bin/ngrok version
ls -al ~/.ngrok2
brew info nginx
brew info php
brew info openssl
openssl version -a
openssl ciphers
sudo nginx -t
which -a php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.0/php-fpm.conf --test
ls -al ~/Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchDaemons | grep homebrew
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."
ls -aln /etc/resolv.conf
cat /etc/resolv.conf
ifconfig lo0
sh -c 'echo "------\n/opt/homebrew/etc/nginx/valet/valet.conf\n---\n"; cat /opt/homebrew/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'