Giter Site home page Giter Site logo

Comments (101)

mattstauffer avatar mattstauffer commented on August 15, 2024 58

Success here as well, using this: #1433 (comment)

So, a quick summary:

Our issue seems to be with how macOS has, lately, put tighter restrictions on multithreading, and that seems to be relevant only when Homebrew PHP is connecting to Postgres and Mongo. I don't know why yet but it's related to something updated by Homebrew, not Valet.

The (temporary) fix

The temporary solution is to update your Homebrew PHP configuration.

Find the config file (it'll be named homebrew.mxcl.php.plist and it'll be in your Homebrew location, /usr/local/ or /etc/homebrew, under the folder Cellar/php/8.2.8, assuming you're on PHP 8.2.8).

Edit that file and add the following:

	<key>EnvironmentVariables</key>
	<dict>
	    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
	    <string>YES</string>
	</dict>

You'll add this directly under this line:

	<key>RunAtLoad</key>
	<true/>

Now run valet restart and try again.

If that doesn't fix it, let's do a little more cleanup.

  • Run brew services stop php to make sure you're not running PHP as your individual user (it should run as root)
  • Delete any homebrew.mxcl.php.plist files that are in ~/Library/LaunchAgents (this is the list of launch agents for your individual user)
  • Delete the php82 sock file (~/.config/valet/valet82.sock) and then valet install again

Try again. That should fix it for everyone, according to our debugging so far here.

What's next?

I'd love for us to figure out why this problem is happening, but it does seem a bit daunting.

from valet.

askdkc avatar askdkc commented on August 15, 2024 11

OK folks! Using this info reported by @djfhe I found the work around for this problem.

(I assume, yo all run brew upgrade and php version is 8.2.8)

vi /opt/homebrew/Cellar/php/8.2.8/homebrew.mxcl.php.plist

change the content of homebrew.mxcl.php.plist file like this:
https://gist.github.com/askdkc/28480a0af1301993d92187920abec3bc

Then run

valet restart

Now everything working perfectly fine with PostgreSQL!!

from valet.

tpetry avatar tpetry commented on August 15, 2024 9

Having the same problem. The error only happens when a PostgreSQL query is executed. I did not use the session driver.

from valet.

Dillonsmart avatar Dillonsmart commented on August 15, 2024 9

Success here as well, using this: #1433 (comment)

So, a quick summary:

Our issue seems to be with how macOS has, lately, put tighter restrictions on multithreading, and that seems to be relevant only when Homebrew PHP is connecting to Postgres and Mongo. I don't know why yet but it's related to something updated by Homebrew, not Valet.

The (temporary) fix

The temporary solution is to update your Homebrew PHP configuration.

Find the config file (it'll be named homebrew.mxcl.php.plist and it'll be in your Homebrew location, /usr/local/ or /etc/homebrew, under the folder Cellar/php/8.2.8, assuming you're on PHP 8.2.8).

Edit that file and add the following:

	<key>EnvironmentVariables</key>
	<dict>
	    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
	    <string>YES</string>
	</dict>

You'll add this directly under this line:

	<key>RunAtLoad</key>
	<true/>

Now run valet restart and try again.

If that doesn't fix it, let's do a little more cleanup.

* Run `brew services stop php` to make sure you're not running PHP as your individual user (it should run as root)

* Delete any `homebrew.mxcl.php.plist` files that are in `~/Library/LaunchAgents` (this is the list of launch agents for your individual user)

* Delete the `php82` sock file (`~/.config/valet/valet82.sock`) and then `valet install` again

Try again. That should fix it for everyone, according to our debugging so far here.

What's next?

I'd love for us to figure out why this problem is happening, but it does seem a bit daunting.

The second part of this answer worked for me! Thanks for sharing!

from valet.

tpetry avatar tpetry commented on August 15, 2024 7

Sure, it is straightforward to reproduce: https://github.com/tpetry/laravel-valet-bug-1433

The only change to a stock Laravel installation is that the / route executes a PostgreSQL query.

php artisan serve

works perfectly!

valet link

fails with nginx 502 error, no information in php-fpm error log.

2023/07/26 16:21:17 [error] 28667#0: *16 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/tpetry/.config/valet/valet.sock:", host: "valet-1433.test"

from valet.

tpetry avatar tpetry commented on August 15, 2024 6

I am on an M1 machine and haven't installed Herd yet.

Laravel Valet: 4.1.3
PHP: 8.2.8
nginx: 1.25.1

from valet.

studnitz avatar studnitz commented on August 15, 2024 6

*.plist files can be read and edited with the defaults program. And because usually the prefix for homebrew is in $HOMEBREW_PREFIX, we can use a one-liner to fix this problem. Existing values for EnvironmentVariables will be overwritten, if you want to just add a value use -dict-add instead of -dict.

defaults write $HOMEBREW_PREFIX/Cellar/php/8.2.9/homebrew.mxcl.php EnvironmentVariables -dict OBJC_DISABLE_INITIALIZE_FORK_SAFETY -string YES

from valet.

ThunderBirdsX3 avatar ThunderBirdsX3 commented on August 15, 2024 6

@efureev
Guys, I try a lot of possible ways from comments. Finally it work.

Here solution, But I'm not sure which one make it work. Or all of them.

Add this code to /usr/local/etc/php/8.2/php-fpm.d/valet-fpm.conf

env['PGGSSENCMODE'] = disable

Add this code to /usr/local/Cellar/php/8.2.11/homebrew.mxcl.php.plist

        <key>EnvironmentVariables</key>
	<dict>
		<key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
		<string>YES</string>
	</dict>

Then valet restart

from valet.

ZacharyDuBois avatar ZacharyDuBois commented on August 15, 2024 5

Was having issues with route model binding (both Implicit and explicit) where I'd either get the 502 error or Laravel would initialize a blank instance of a model instead of looking up the existing one. This only occurred if Valet was serving the site. If I used the built in php artisan serve everything worked as expected.

Updating /Library/LaunchDaemons/homebrew.mxcl.php.plist and adding the OBJC_DISABLE_INITIALIZE_FORK_SAFETY environment variable fixed this. This is also a major issue with Rails/Sinatra + Puma and various Python frameworks too.

	<key>EnvironmentVariables</key>
	<dict>
	    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
	    <string>YES</string>
	</dict>

Thank you so much for reminding me that this issue causes a lot of havoc @askdkc !

from valet.

steinmb avatar steinmb commented on August 15, 2024 5

Ref - Homebrew/homebrew-core#137431 (comment)

This worked for me: Add the following lines to your /usr/local/etc/php/<PHPVERSION>/php-fpm.d/www.conf Example /usr/local/etc/php/8.4/php-fpm.d/www.conf

;Signal 11 workaround
env['PGGSSENCMODE'] = disable
env['LC_ALL'] = C

And restart your effected PHP service, or test in running it directly: /usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize

Needed this on all mine PHP versions, to make it work:

  • PHP 7.4
  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3
  • PHP 8.4

from valet.

pascal-kubrick avatar pascal-kubrick commented on August 15, 2024 4

OK folks! Using this info reported by @djfhe I found the work around for this problem.

(I assume, yo all run brew upgrade and php version is 8.2.8)

vi /opt/homebrew/Cellar/php/8.2.8/homebrew.mxcl.php.plist

change the content of homebrew.mxcl.php.plist file like this: https://gist.github.com/askdkc/28480a0af1301993d92187920abec3bc

Then run

valet restart

Now everything working perfectly fine with PostgreSQL!!

This worked for me but my .plist is a bit different - probably because I'm still on 8.1.

Only needed to add this part + valet restart:

    <key>EnvironmentVariables</key>
    <dict>
      <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
      <string>YES</string>
    </dict>

Fwiw, I'm using Drupal 9.5 and MySql 5.7, some paths on a single project returned a 502, everything else worked fine.

Thanks a lot!

from valet.

drbyte avatar drbyte commented on August 15, 2024 4

@danielcommesse wrote: Found a solution here: Homebrew/homebrew-core#137431 (comment)

Note that for Valet, the .conf filename would be different. Valet uses the php-fpm pool defined in /usr/local/etc/php/8.2/php-fpm.d/valet-fpm.conf (and during install, deletes/renames the default www.conf file to prevent conflicts)

from valet.

drbyte avatar drbyte commented on August 15, 2024 3

I guess the new Valet version has strange behaviour

I'm pretty sure this is a homebrew package issue, not specific to Valet's internals. The challenge is figuring out "what" specifically.

So, reverting back to an older Valet version won't solve the problem, since you're probably using recent Homebrew package versions, and downgrading those is actually kinda complicated.

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024 3

Thanks so much for your work @askdkc! And as always, fantastic work @drbyte!

Looks like we know the source of the issue, and it's upstream; we have a PR to Homebrew and an issue with PHP src.

We also have a temporary fix for Valet users.

from valet.

askdkc avatar askdkc commented on August 15, 2024 3

@mattstauffer

It’s my pleasure. And Laravel forever👍😉

from valet.

askdkc avatar askdkc commented on August 15, 2024 3

Hey Artisans!

I'm sorry, my PR didn't get merged and now it closed.

Homebrew/homebrew-core#137909

We need manually handle this error when it happens.

I'm kinda sad it didn't help🥲

from valet.

matthewpaulking avatar matthewpaulking commented on August 15, 2024 3

For anyone still struggling with Postgres issues, try adding PGGSSENCMODE=disable to your ~/.zshrc and restart the postgres service.

I discovered this workaround via some issues in the Rails community:
rails/rails#38560 (comment)
ged/ruby-pg#538 (comment)

I really don't understand why this works or the implications of disabling this, but it seems to have solved an issue where interacting with my local Postgres database (postgresql@14 installed via homebrew) in artisan tinker would randomly stop working (although it would reliably start happening after connecting to my work VPN). For example, running DB::connection()->getPdo() or User::all() would abruptly end the tinker process.

At the same time, I was also getting the 502 errors with the php-fpm segfaults. In my case I was using Caddy Server. This solved by switching from Caddy to Valet and applying the OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES environment variable (hooray Valet!). Not sure if these are even related issues, but like many others I started having these issues after a brew upgrade

from valet.

efureev avatar efureev commented on August 15, 2024 3

@ThunderBirdsX3 thx! but I'm helped following:
At file: /usr/local/etc/php/8.2/php-fpm.d/www.conf add lines:

env['PGGSSENCMODE'] = disable
env['LC_ALL'] = C

And restart php. It works fine.

from valet.

faltjo avatar faltjo commented on August 15, 2024 2

I also struggled with this for the last days and was not able to resolve it. All laravel projects which were using pgsql resulted in 502 and the error message mentioned here. It may have something to do with Homebrew/homebrew-core#137431. Even though the fix mentioned there did not work for me and the SIGABRT did not show up in php-fpm.log on my side.

My current 'workaround' is to use Herd, since pgsql extension was included there recently. Apparently their php build does not include the gettext method.

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024 2

Update: I tried all these same steps on my m1 laptop, same inability to reproduce.

... until I restarted my computer! Now I can reproduce! Let me try restarting my non-m1.... yep. So.. it's not m1 related either.

Update homebrew, restart computer, suddenly seeing the problem. Now let's dive into why...

from valet.

djfhe avatar djfhe commented on August 15, 2024 2

Wenn enabling

catch_workers_output = yes

in /out/homebrew/etc/php/8.2/php-fpm.d/valet-fpm.conf

i get additional error output:

[27-Jul-2023 09:49:38] NOTICE: ready to handle connections
[27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 said into stderr: "objc[54119]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called."
[27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 said into stderr: "objc[54119]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug."
[27-Jul-2023 09:49:48] WARNING: [pool valet] child 54119 exited on signal 6 (SIGABRT) after 9.676681 seconds from start
[27-Jul-2023 09:49:48] NOTICE: [pool valet] child 54693 started
[27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 said into stderr: "objc[54120]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called."
[27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 said into stderr: "objc[54120]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug."
[27-Jul-2023 09:50:29] WARNING: [pool valet] child 54120 exited on signal 6 (SIGABRT) after 50.322856 seconds from start
[27-Jul-2023 09:50:29] NOTICE: [pool valet] child 54703 started

no clue what that means haha

from valet.

tychoengberink avatar tychoengberink commented on August 15, 2024 2

This is what i did. Thanks to @askdkc for the first part!

vi /opt/homebrew/Cellar/php/8.2.8/homebrew.mxcl.php.plist
Change the content of homebrew.mxcl.php.plist file like this:
https://gist.github.com/askdkc/28480a0af1301993d92187920abec3bc

Remove old socket
rm -rf /Users/<USERNAME>/.config/valet/valet82.soc
Reinstall socket
valet install

This fixed 8.2.8 for me. It also fixes older versions (8.1.21) on which I had 502 errors.

Also update the plist file, remove the soc file for each version. When done with each version. Run valet install

I assume php-fpm crashes when using extensions. When I disable my database credentials I get an connection exception but when I enable them, I get 502 errors.

php-fpm logs:
[27-Jul-2023 17:23:15] WARNING: [pool valet] child 66302 exited on signal 9 (SIGKILL) after 1.389545 seconds from start
[27-Jul-2023 17:23:15] NOTICE: [pool valet] child 66325 started

nginx logs:
2023/07/27 17:25:43 [error] 66354#0: *10 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1

I have no plist files in /Library/LaunchAgents and the ones /Library/LaunchDaemons/ matches the ones I edited

from valet.

sashko-guz avatar sashko-guz commented on August 15, 2024 2

#1433 (comment)

This workaround is not working for me

I have project with php 8.2.8, but some pages not working, and this is so strange (yes, its 502 nginx error)
there is no mongo/postgresql usage in project

I've updated content of php homebrew .plist files, restart and reinstall valet many times. There is no changes:

  • some routes working fine
  • another — got an error from nginx

I think some extension is an issue, just researching

UPDATE

The problem is usage of gettext (underscore "_") function for gettext

After usage of next line page is working fine (setting LC_ALL locale via putenv)

putenv('LC_ALL=uk_UA');

Maybe, it helps for future investigation of problem


Same problem, another troubleshooting #Homebrew/homebrew-core#137431

from valet.

danielcommesse avatar danielcommesse commented on August 15, 2024 2

Found a solution here: Homebrew/homebrew-core#137431 (comment)

from valet.

efureev avatar efureev commented on August 15, 2024 2

I'm getting this errors with PG without Valet.

Working through localhost (127.0.0.1:port) - normal (`./artisan serve):
Снимок экрана 2023-09-29 в 02 15 49

But working through nginx & domain (e.g. example.com) - failed on Creating PDO connection:

$dbh = new \PDO('pgsql:dbname=dbname;host=127.0.0.1', $user, $password);
Снимок экрана 2023-09-29 в 02 16 58

Code the same!
Снимок экрана 2023-09-29 в 02 18 28

PHP: 8.2.11
OS: MacOs 14
PG: 14

from valet.

lewislarsen avatar lewislarsen commented on August 15, 2024 2

My path is slightly different with it being /opt/homebrew/Cellar/php/8.2.11 but the changes to homebrew.mxcl.php.plist fixed my 502 Bad Gateway problems.

(#1433 (comment) Lifesaver!)

Thanks for this again! I had fixed it on my machine a few months ago but had to reinstall Valet and it all fell apart.

from valet.

monoland avatar monoland commented on August 15, 2024 1

I've been looking for a solution all day in every forum and even reinstalling macOS, if I use SESSION_DRIVER other than database valet was OK

from valet.

monoland avatar monoland commented on August 15, 2024 1

and if anyone has same problem, just switch back to valet v4.1.2 and session_driver=database was runing good. thanks

from valet.

monoland avatar monoland commented on August 15, 2024 1

this my nginx error log

2023/07/24 07:06:16 [error] 1957#0: *2 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: backend.citragroup.test, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/Users/monoland/.config/valet/valet.sock:", host: "backend.citragroup.test"

from valet.

monoland avatar monoland commented on August 15, 2024 1

@djfhe my-problem appear when I install redis on my-machine

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

I tried to fresh install macOS on my M1 MacBook Air and hopefully this problem gets solved, but no help.

Here is what I did:

Reinstall macOS

boot mac in rescue mode, and clean install macOS.

Setup Laravel Environment

Install homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install php and Laravel Valet

brew update
brew install php
brew install composer
brew install postgresql

composer global require laravel/installer
composer global require laravel/valet

mkdir -p ~/Sites
cd ~/Sites
valet install
valet park

laravel new laravel

Create PostgreSQL DB

createdb laravel

Change .env to use PostgreSQL

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=username
DB_PASSWORD=

For testing use Laravel Breeze

composer require laravel/breeze --dev
php artisan breeze:install blade

php artisan migrate

Access Top Page

Open your browser and access to : http://laravel.test <- This works fine.

Now, try to register a user from Breeze register menu, then it throws a 502 error.

If you switch your db from PostgreSQL to sqlite or MySQL, it works just fine.

Other Environment

I have another Intel iMac, so I also tested with it.
Before running the commands below, Valet was working without any problem.

brew update && brew upgrade then composer g update && valet install && valet restart

Now, using PostgreSQL throws 502.

I guess there is something wrong with homebrew packages, not Valet itself, but not sure.

We can use previous or older version of Valet by editing ~/.composer/composer.json like this:

"laravel/valet": "^4.1" -> "laravel/valet": "4.0.0"

Then run composer g update this will change Valet version (back to 4.0.0 in this case), but when I access to Laravel Project, it still throws 502 error.
If this is related to Valet recent changes, this shouldn't be happening.

So, it must be related to brew package updates, either php or nginx?

from valet.

djfhe avatar djfhe commented on August 15, 2024 1

Interesting, i tried the same, by adding

fastcgi_param OBJC_DISABLE_INITIALIZE_FORK_SAFETY YES;

to the ngninx config, but that didn't work for me.
Your solution does @askdkc, thanks!

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024 1

@SanderMuller

Interesting. Did you run brew upgrade? Which php version are you using? 8.2.8?

Yes, it all worked fine until I upgraded everything to try and debug an unrelated issue.
Before upgrade I ran PHP 8.2.3, OpenSSL 1.1, outdated Valet
After upgrade I run PHP 8.2.8, OpenSSL 3, latest Valet

Did brew upgrade, reinstalled valet (uninstall force, valet install)

FYI my issue is not with postgress, we don't use that. But I get exactly the same issue with mongodb.
All my applications work fine, except for one which uses mongodb, and that application works fine except for pages where mongodb is actually queried.

Try directly change /Library/LaunchDaemons/homebrew.mxcl.php.plist then without doing anything, just reboot your Mac. See how it goes?

I have done this, but it has no effect.

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024 1

@SanderMuller

Usually it should be this line in your mongodb plist :

・・・
<key>RunAtLoad</key>
<true/>
   ↑ UNDER THIS LINE
<key>EnvironmentVariables</key>
・・・

I replaced my cloud mongo with mongodb-community via brew and that works without setting OBJC_DISABLE_INITIALIZE_FORK_SAFETY in the plist. The cloud connection ****.azure.mongodb.net still gives this 502, but at least I can get it working. Thanks a lot!

from valet.

drbyte avatar drbyte commented on August 15, 2024 1

I'd love for us to figure out why this problem is happening, but it does seem a bit daunting.

I wonder if it started with the recompile to OpenSSL 3 instead of 1.1, starting with PHP 8.2.7_2
Ref: https://github.com/Homebrew/homebrew-core/commits/8bb12900d3df7365db4c81b1e3b48842d467d265/Formula/php.rb

PHP 8.1 (8.1.20_2) also got recompiled to OpenSSL 3 at the same time

But PHP 8.0 has not because they've deprecated it: https://github.com/Homebrew/homebrew-core/blob/8bb12900d3df7365db4c81b1e3b48842d467d265/Formula/php%408.0.rb#L28-L49

But then again, there are other reports of homebrew packages including pgsql and php-with-gettext segfaulting:
Homebrew/homebrew-core#137431
Homebrew/homebrew-core#136432
Homebrew/homebrew-core#135170

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

I think it's better to fix this issue from Homebrew side. So I created the PR to fix this issue by adding some env to Homebrew php formula. Hopefully it gets merged. I tested with my Mac and it works like a charm☺️

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

Hey folks.

I also reported this issue to PHP team.

php/php-src#11818

from valet.

monoland avatar monoland commented on August 15, 2024 1

Thanks @askdkc!, it's awesome work.

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

@sashko-guz

Interesting! @faltjo also reported it’s related with gettext in this comment.

#1433 (comment)

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

Hey Artisans.

This is more of a system-level issue than a PHP issue after all. And upstream PHP member confirmed it.
php/php-src#11818 (comment)

It seems there is no easy fix here.

Hopefully my PR (Homebrew/homebrew-core#137909) gets merged and makes our life much easier.

from valet.

stubbo avatar stubbo commented on August 15, 2024 1

I just built the Mongo extension with OpenSSL and it seems to work fine.

Seems to be an issue with Secure Transport found this log after adding mongodb.debug = stderr to my ini file
stream-tls-secure_transport: TRACE > ENTRY: mongoc_stream_tls_secure_transport_new():666

from valet.

drbyte avatar drbyte commented on August 15, 2024 1

I just build the Mongo extension with OpenSSL and it seems to work fine.

Seems to be an issue with Secure Transport found this log after adding mongodb.debug = stderr to my ini file stream-tls-secure_transport: TRACE > ENTRY: mongoc_stream_tls_secure_transport_new():666

Which version of OpenSSL?
Most of the PHP versions currently being reported as troublesome have been compiled with openssl 3, instead of the older soon-to-be-deprecated 1.1

from valet.

nikuscs avatar nikuscs commented on August 15, 2024 1

Same issue today after upgrading homebrew

here is a little bash script to do this for all the PHP versions found, since i often have to deal with multiple verisons installed and im lazy :p , feel free to tweak it, i only tested a few times

#!/bin/bash

# Define the directory where the search should begin
# NOTE: Change to whatever your homebrew path is.
BASE_DIR="/opt/homebrew/Cellar"

# Use find to look for files matching the pattern
for plist in $(find $BASE_DIR/php* -type f -name "homebrew.mxcl.php*.plist"); do

    # Check if the file already contains the EnvironmentVariables key
    if ! grep -q "EnvironmentVariables" "$plist"; then
    
        # Use awk to insert content after the string
        awk '
        /<key>RunAtLoad<\/key>/ {
            print
            print "<key>EnvironmentVariables</key>"
            print "<dict>"
            print "<key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>"
            print "<string>YES</string>"
            print "</dict>"
            next
        } 
        1' "$plist" > "${plist}.tmp"
        
        # Move the temporary file back to the original
        mv "${plist}.tmp" "$plist"
    fi

done

from valet.

askdkc avatar askdkc commented on August 15, 2024 1

@sajaddp

Homebrew workaround PR is unmerged and closed. (Unfortunately!)

Homebrew/homebrew-core#137909

PHP itself cannot fix this because this problem is rooted in macOS system-level issue.

php/php-src#11818

from valet.

dentarg avatar dentarg commented on August 15, 2024 1

Not sure if these are even related issues, but like many others I started having these issues after a brew upgrade

Homebrew/homebrew-core#132976, merged 2023-06-07 updated the krb5 formula from 1.20 to 1.21 which brought in krb5/krb5#1221 – that is now defeating the workaround added with Homebrew/homebrew-core@b5c3775 ("GSSAPI provided by Kerberos.framework crashes when forked")

from valet.

driesvints avatar driesvints commented on August 15, 2024 1

Closing this since a PR is up. Thanks all.

from valet.

zhangzhecomiru avatar zhangzhecomiru commented on August 15, 2024 1

on my mac, the file location of Homebrew is in

/opt/homebrew/Cellar/[email protected]/7.3.33_8

try this if you can not find in /usr/local/ or /etc/homebrew

from valet.

driesvints avatar driesvints commented on August 15, 2024

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

from valet.

drbyte avatar drbyte commented on August 15, 2024

@monoland
A 502 error reported by Nginx will be recorded in the Nginx server logs, with details about the actual cause of the error.
Can you share those details? It will help us confirm whether there's any bug in Valet.

You will probably find those details in /Users/your_username/.config/valet/Log/nginx-error.log

from valet.

drbyte avatar drbyte commented on August 15, 2024

I've finally had time to test the situation described, and cannot replicate the problem, using both Valet 4.1.2 and 4.1.3.
(The change from 4.1.2 to 4.1.3 was extremely minor, and had no relationship to database factors.)

cd ~/Sites
laravel new foo
cd foo
valet open
sed -i '' 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i '' 's/DB_DATABASE=/#DB_DATABASE=/' .env
touch database/database.sqlite
php artisan session:table
php artisan migrate
valet open
brew services start mariadb
mysqld -uroot -p   ##logged in and created database
sed -i '' 's/DB_CONNECTION=sqlite/DB_CONNECTION=mysql/' .env
sed -i '' 's/\#DB_DATABASE=/DB_DATABASE=/' .env
php artisan migrate:fresh
valet open

from valet.

djfhe avatar djfhe commented on August 15, 2024

Having the same problem.
I was able to reproduce it in a fresh laravel project with postgres. With sqlite and mysql it works fine. mysql and postgres ran in a docker container.

Works fine, when served via artisan serve

Problems also happens on 4.1.2, so probably not a valet problem, but any help is appreciated :)

valet log php-fpm -f --lines=20

[23-Jul-2023 23:30:30] WARNING: [pool valet] child 57272 exited on signal 6 (SIGABRT) after 44.809516 seconds from start
[23-Jul-2023 23:30:30] NOTICE: [pool valet] child 57458 started
[23-Jul-2023 23:30:32] WARNING: [pool valet] child 57458 exited on signal 9 (SIGKILL) after 1.773915 seconds from start
[23-Jul-2023 23:30:32] NOTICE: [pool valet] child 57463 started
[23-Jul-2023 23:30:33] WARNING: [pool valet] child 57463 exited on signal 6 (SIGABRT) after 1.098928 seconds from start
[23-Jul-2023 23:30:33] NOTICE: [pool valet] child 57471 started
[23-Jul-2023 23:30:34] WARNING: [pool valet] child 57471 exited on signal 6 (SIGABRT) after 0.927223 seconds from start
[23-Jul-2023 23:30:34] NOTICE: [pool valet] child 57479 started
[23-Jul-2023 23:30:41] WARNING: [pool valet] child 57479 exited on signal 6 (SIGABRT) after 6.795968 seconds from start
[23-Jul-2023 23:30:41] NOTICE: [pool valet] child 57508 started
[23-Jul-2023 23:30:57] WARNING: [pool valet] child 57508 exited on signal 6 (SIGABRT) after 15.500840 seconds from start
[23-Jul-2023 23:30:57] NOTICE: [pool valet] child 57594 started
[23-Jul-2023 23:30:58] WARNING: [pool valet] child 57594 exited on signal 9 (SIGKILL) after 1.113476 seconds from start
[23-Jul-2023 23:30:58] NOTICE: [pool valet] child 57603 started
[23-Jul-2023 23:30:58] WARNING: [pool valet] child 57603 exited on signal 6 (SIGABRT) after 0.830134 seconds from start
[23-Jul-2023 23:30:58] NOTICE: [pool valet] child 57611 started
[23-Jul-2023 23:30:59] WARNING: [pool valet] child 57611 exited on signal 6 (SIGABRT) after 0.694385 seconds from start
[23-Jul-2023 23:30:59] NOTICE: [pool valet] child 57619 started
[23-Jul-2023 23:31:00] WARNING: [pool valet] child 57619 exited on signal 6 (SIGABRT) after 0.576138 seconds from start
[23-Jul-2023 23:31:00] NOTICE: [pool valet] child 57624 started

valet log nginx -f --lines=10

2023/07/23 23:30:30 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:32 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:33 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:34 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:41 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:57 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:58 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:58 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:30:59 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/23 23:31:00 [error] 50639#0: *77 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"

sw_vers
ProductName:		macOS
ProductVersion:		13.4.1
ProductVersionExtra:	(c)
BuildVersion:		22F770820d
valet --version
Laravel Valet 4.1.3
cat ~/.config/valet/config.json
{
    "tld": "test",
    "loopback": "127.0.0.1",
    "paths": [
        "/Users/danielthoma/.config/valet/Sites",
        "/Users/danielthoma/git/clickbar",
        "/Users/danielthoma/git/konaktiva",
        "/Users/danielthoma/git/private"
    ]
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/installer": "^4.4",
        "laravel/valet": "^4.1",
        "tightenco/takeout": "^2.4"
    }
}
composer global diagnose
Changed current directory to /Users/danielthoma/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK git version 2.41.0
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: OK
Composer version: 2.5.8
PHP version: 8.2.8
PHP binary path: /opt/homebrew/Cellar/php/8.2.8/bin/php
OpenSSL version: OpenSSL 3.1.1 30 May 2023
cURL version: 8.2.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/3.1.1
zip: extension present, unzip present, 7-Zip not available
composer global outdated
Changed current directory to /Users/danielthoma/.composer
Legend:
! patch or minor release available - update recommended
~ major release available - update possible

Direct dependencies required in composer.json:
Everything up to date

Transitive dependencies not required in composer.json:
guzzlehttp/psr7 1.9.1 ~ 2.5.0 PSR-7 message implementation that also provid...
psr/http-message 1.1 ~ 2.0 Common interface for HTTP messages

ls -al /etc/sudoers.d/
total 0
drwxr-xr-x   2 root  wheel    64 Jun 15 12:08 .
drwxr-xr-x  80 root  wheel  2560 Jul 16 14:28 ..
brew config
HOMEBREW_VERSION: 4.1.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: ac93842f8d13913f462aedb246cfacd08d6b7f05
Last commit: 4 days ago
Core tap origin: https://github.com/Homebrew/homebrew-core
Core tap HEAD: eb3088f5a5ebd859a4999f1d1f2403b9e6f88126
Core tap last commit: 5 months ago
Core tap branch: master
Core tap JSON: 23 Jul 21:39 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 14.0.3 build 1403
Git: 2.41.0 => /opt/homebrew/bin/git
Curl: 7.88.1 => /usr/bin/curl
macOS: 13.4.1-arm64
CLT: 14.3.1.0.1.1683849156
Xcode: N/A
Rosetta 2: false
brew services list
Name          Status User File
dnsmasq       none            root 
meilisearch   none                 
nginx         none            root 
openvpn       none                 
php           started         root ~/Library/LaunchAgents/homebrew.mxcl.php.plist
[email protected]       none                 
postgresql@14 none                 
stripe-mock   none                 
unbound       none
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.87 2.89 2.88 2.86
nginx 1.25.1_1 1.25.1
[email protected] 1.1.1u
php 8.1.12 8.2.7 8.2.8 8.2.6 8.1.3_1 8.2.7_1 8.1.7 8.1.10 8.1.11 8.2.3 8.2.4 8.2.5 8.2.7_2 8.1.10_1 8.1.5
[email protected] 8.1.21 8.1.14_1
brew outdated

brew tap
homebrew/bundle
homebrew/cask
homebrew/cask-fonts
homebrew/cask-versions
homebrew/core
homebrew/services
nicoverbruggen/cask
oven-sh/bun
stripe/stripe-cli
stripe/stripe-mock
traildb/judy
php -v
PHP 8.2.8 (cli) (built: Jul  6 2023 10:57:44) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies
which -a php
/opt/homebrew/bin/php
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.2
Loaded Configuration File:         /opt/homebrew/etc/php/8.2/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.2/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.2/conf.d/99-memprof.ini,
/opt/homebrew/etc/php/8.2/conf.d/99-xdebug.ini,
/opt/homebrew/etc/php/8.2/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.2/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.25.1
curl --version
curl 7.88.1 (x86_64-apple-darwin22.0) libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
Release-Date: 2023-02-20
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 8.2.0
Age => 10
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
ALTSVC => Yes
HTTP3 => No
UNICODE => No
ZSTD => Yes
HSTS => Yes
GSASL => No
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtmpe, rtmps, rtmpt, rtmpte, rtmpts, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => aarch64-apple-darwin22.4.0
SSL Version => (SecureTransport) OpenSSL/3.1.1
ZLib Version => 1.2.11
libSSH Version => libssh2/1.11.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value

/opt/homebrew/bin/ngrok version
sudo: /opt/homebrew/bin/ngrok: command not found
ls -al ~/.ngrok2
ls: /Users/danielthoma/.ngrok2: No such file or directory
brew info nginx
==> nginx: stable 1.25.1 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/opt/homebrew/Cellar/nginx/1.25.1 (23 files, 2.4MB)
  Built from source
/opt/homebrew/Cellar/nginx/1.25.1_1 (26 files, 2.4MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-06-29 at 09:37:25
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@3, pcre2
==> Options
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/nginx/bin/nginx -g daemon off;
==> Analytics
install: 15,746 (30 days), 56,605 (90 days), 75,889 (365 days)
install-on-request: 15,727 (30 days), 56,531 (90 days), 75,784 (365 days)
build-error: 4 (30 days)

brew info php
==> php: stable 8.2.8 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/opt/homebrew/Cellar/php/8.1.3_1 (510 files, 81.6MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.5 (510 files, 81.6MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.7 (510 files, 81.7MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.10 (510 files, 81.7MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.10_1 (510 files, 81.7MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.11 (510 files, 81.6MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.12 (510 files, 81.6MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.3 (517 files, 83.3MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.4 (516 files, 83.3MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.5 (517 files, 83.4MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.6 (517 files, 83.4MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.7 (517 files, 83.4MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.7_1 (517 files, 83.4MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.7_2 (517 files, 83.4MB)
  Built from source
/opt/homebrew/Cellar/php/8.2.8 (520 files, 83.5MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-07-11 at 13:09:28
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, openldap, openssl@3, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
	Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
/opt/homebrew/etc/php/8.2/

To restart php after an upgrade:
brew services restart php
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 44,803 (30 days), 161,631 (90 days), 213,623 (365 days)
install-on-request: 41,303 (30 days), 149,638 (90 days), 197,731 (365 days)
build-error: 60 (30 days)

brew info openssl
==> openssl@3: stable 3.1.1 (bottled)
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/openssl@3/3.1.1_1 (6,495 files, 28.4MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-06-29 at 09:36:57
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: Apache-2.0
==> Dependencies
Required: ca-certificates
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/openssl@3/certs

and run
/opt/homebrew/opt/openssl@3/bin/c_rehash
==> Analytics
install: 322,150 (30 days), 702,232 (90 days), 848,810 (365 days)
install-on-request: 36,559 (30 days), 185,673 (90 days), 226,328 (365 days)
build-error: 1,076 (30 days)

openssl version -a
OpenSSL 1.1.1t  7 Feb 2023
built on: Mon Feb 13 23:21:47 2023 UTC
platform: darwin64-arm64-cc
options:  bn(64,64) rc4(int) des(int) idea(int) blowfish(ptr) 
compiler: arm64-apple-darwin20.0.0-clang -D_FORTIFY_SOURCE=2 -isystem /opt/homebrew/Caskroom/miniconda/base/include -mmacosx-version-min=11.1 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/homebrew/Caskroom/miniconda/base/include -fdebug-prefix-map=/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_ccl4lztlvr/croot/openssl_1676330477401/work=/usr/local/src/conda/openssl-1.1.1t -fdebug-prefix-map=/opt/homebrew/Caskroom/miniconda/base=/usr/local/src/conda-prefix -fPIC -arch arm64 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/homebrew/Caskroom/miniconda/base/include -fdebug-prefix-map=/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/abs_ccl4lztlvr/croot/openssl_1676330477401/work=/usr/local/src/conda/openssl-1.1.1t -fdebug-prefix-map=/opt/homebrew/Caskroom/miniconda/base=/usr/local/src/conda-prefix -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG -D_FORTIFY_SOURCE=2 -isystem /opt/homebrew/Caskroom/miniconda/base/include -mmacosx-version-min=11.1
OPENSSLDIR: "/opt/homebrew/Caskroom/miniconda/base/ssl"
ENGINESDIR: "/opt/homebrew/Caskroom/miniconda/base/lib/engines-1.1"
Seeding source: os-specific
openssl ciphers
TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:RSA-PSK-AES256-GCM-SHA384:DHE-PSK-AES256-GCM-SHA384:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:PSK-CHACHA20-POLY1305:RSA-PSK-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256:AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:ECDHE-PSK-AES256-CBC-SHA384:ECDHE-PSK-AES256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:SRP-AES-256-CBC-SHA:RSA-PSK-AES256-CBC-SHA384:DHE-PSK-AES256-CBC-SHA384:RSA-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA:AES256-SHA:PSK-AES256-CBC-SHA384:PSK-AES256-CBC-SHA:ECDHE-PSK-AES128-CBC-SHA256:ECDHE-PSK-AES128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:SRP-AES-128-CBC-SHA:RSA-PSK-AES128-CBC-SHA256:DHE-PSK-AES128-CBC-SHA256:RSA-PSK-AES128-CBC-SHA:DHE-PSK-AES128-CBC-SHA:AES128-SHA:PSK-AES128-CBC-SHA256:PSK-AES128-CBC-SHA
sudo nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
which -a php-fpm
/opt/homebrew/sbin/php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
PHP 8.2.8 (fpm-fcgi) (built: Jul  6 2023 10:57:47)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.2/php-fpm.conf --test
[23-Jul-2023 23:39:39] NOTICE: configuration file /opt/homebrew/etc/php/8.2/php-fpm.conf test is successful
ls -al ~/Library/LaunchAgents | grep homebrew
-rw-r--r--   1 danielthoma  staff   586 Mar 24  2022 homebrew.mxcl.php.plist
ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   797 Jul 23 23:04 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   685 Jul 23 23:04 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   781 Jul 23 23:04 homebrew.mxcl.php.plist
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22 Jun 15 12:08 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search fritz.box
nameserver 1.1.1.1
nameserver 8.8.8.8
ifconfig lo0
lo0: flags=8049 mtu 16384
	options=1203
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=201
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"'
------
/opt/homebrew/etc/nginx/valet/valet.conf
---

3: #listen VALET_LOOPBACK:80; # valet loopback

------

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'
------
~/.config/valet/dnsmasq.d/tld-test.conf
---

address=/.test/127.0.0.1
listen-address=127.0.0.1

------

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'
------
~/.config/valet/nginx/*
---

cat: /Users/danielthoma/.config/valet/nginx/*: No such file or directory

------

from valet.

StringKe avatar StringKe commented on August 15, 2024

I had the same problem and found some differences in my debugging

Illuminate\Foundation\Http\Kernal.sendRequestThroughRouter Pipeline.then

in artisan server

CleanShot 2023-07-26 at 15 54 58@2x

in valet
CleanShot 2023-07-26 at 15 56 42@2x

from valet.

driesvints avatar driesvints commented on August 15, 2024

We'll need a clear way to reproduce this one otherwise it's gonna be a shot in the dark at figuring out how to solve it.

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024

I'm working on getting Postgres working on my local machine after a while of not using it; will test as soon as I have it running.

Update:
Running Postgres.app on Valet 4.1.0 renders the app with no problems.

I ran composer global update laravel/valet and now I'm on Valet 4.1.3. No problems.

So this isn't a core Valet issue, as I think we're all assuming.

I'm going to assume it's some dependency that y'all have a newer version of than me. Let me work on updating them all bit by bit.

Possible things that have been mentioned:

I don't have any m2 machines so if it's that I'll need help. I'm going to update all my dependencies and see if I can possibly trigger this; if not, I'll install Herd and see if it causes the problem; if not, M2 is my next angle.

from valet.

alfonsobries avatar alfonsobries commented on August 15, 2024

Same issue, even tried in a fresh m2 machine (nothing installed other than valet and neccessary stuff to run a Laravel project), on a fresh laravel project it fails once I set the database driver to pgsql, dame nginx logs as the ones pointed in other comments

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024

OK, @tpetry has disproved the Herd hypothesis and the M2 hypothesis. Let's see what else we can find out...

from valet.

drbyte avatar drbyte commented on August 15, 2024

from valet.

tpetry avatar tpetry commented on August 15, 2024

I guess that the problem started after brew updated my dependencies. But I am not sure. I hadn't been developing for some days and the day I started to develop again I've installed a new brew package - which updated everything.

Again, just a guess.

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024

I'm running on a pre-m1 iMac; I'll run these tests on my m1 laptop again later.

I ran brew upgrade several times to make sure I was entirely up to date; still no problem.

I'm currently on PHP 8.2.8, Valet 4.1.3, and nginx 1.25.1, same as @tpetry, but can't repro the problem.

@tpetry What tool are you using to install your Postgres? I'm using postgres.app, but maybe if I use the same one you're using that'll help us be in better parity?

To be clear, what I'm testing is:

from valet.

tpetry avatar tpetry commented on August 15, 2024

I am using a PG 14 version of StackBricks. But the Postgres version shouldn't be the problem. Because for a PG issue the laravel.log should have some information - but that is empty.

from valet.

drbyte avatar drbyte commented on August 15, 2024

While it's unknown here yet which "upstream" host/phase is actually the "delay" or causing the "disconnect", perhaps (even just temporarily for troubleshooting) adjusting the nginx config may help expose more errors in other logs:

Add new file:
/usr/local/etc/nginx/servers/temp_fastcgi_settings.conf
(edit: adjust the path if you're on M1 or M2, it's in the /opt/homebrew/etc/ subtree)
containing:

# The following settings can be adjusted for your environment

#### Connections and Responses to Upstream may be impacted by upstream hosts

# If connection can't be made within this timeframe, connection is closed; default 60s, max 75s.
fastcgi_connect_timeout 75s;

# If no responses are read for this length of time, connection is closed. Default 60s
fastcgi_read_timeout 360s;

# Determines whether the connection with a FastCGI server should be closed when a client closes the connection without waiting for a response. Default is off.
fastcgi_ignore_client_abort on;


# https://gist.github.com/magnetikonline/11312172#determine-fastcgi-response-sizes
# http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html

... and valet restart

from valet.

drbyte avatar drbyte commented on August 15, 2024

In the reports above I've observed that the number "before" the "upstream prematurely closed" varies. So far it's *2, *77, *16. I'm not sure if that's significant:

[error] 1957#0: *2 upstream prematurely closed connection
[error] 50639#0: *77 upstream prematurely closed connection
[error] 28667#0: *16 upstream prematurely closed connection

EDIT: after digging into nginx source, I'm pretty sure 1957#0: *2 refers to pid#tid: *connectionid from nginx internals ... so the *xx value is not particularly helpful here because we probably can't identify it easily.

However, if the pid matches a process running on the Mac which is operating as user instead of as root then perhaps that's a clue to the LaunchAgents topic I posted about in the post below. But of course it's harder to research in hindsight especially after reboots and service-restarts etc.

from valet.

drbyte avatar drbyte commented on August 15, 2024

@monoland FYI, in your valet diagnose output it shows you've got PHPFPM running both as root and as your non-root user.
That'll potentially create conflicts (may or may not be related to this Issue directly though).

Check the following again:

ls -al ~/Library/LaunchAgents | grep homebrew
ls -al ~/Library/LaunchDaemons | grep homebrew

You don't want a PHP process running in LaunchAgents. Only in LaunchDaemons.

To fix that, simply run (without sudo): brew services stop php (to stop the homebrew.mxcl.php.plist service shown in that LaunchAgents directory). (Doing it with sudo would do the LaunchDaemons, but Valet handles that itself for Valet-specific services.)
Calling brew services stop [name] will stop the service and remove the LaunchAgent file so that it also doesn't restart on login.

from valet.

drbyte avatar drbyte commented on August 15, 2024

I notice the same LaunchAgents issue for @djfhe in his valet diagnose output as well: duplicate PHP processes running both as root and non-root, simultaneously.
To fix, do the same as I posted above.

Due to the pattern showing for both, I wonder: Does that solve the reported issue?

from valet.

djfhe avatar djfhe commented on August 15, 2024

Stopped LaunchAgents (ls -al ~/Library/LaunchAgents | grep homebrew is empty now)
and added your config.

While it's unknown here yet which "upstream" host/phase is actually the "delay" or causing the "disconnect", perhaps (even just temporarily for troubleshooting) adjusting the nginx config may help expose more errors in other logs:

Add new file: /usr/local/etc/nginx/servers/temp_fastcgi_settings.conf (edit: adjust the path if you're on M1 or M2, it's in the /opt/homebrew/etc/ subtree) containing:

# The following settings can be adjusted for your environment

#### Connections and Responses to Upstream may be impacted by upstream hosts

# If connection can't be made within this timeframe, connection is closed; default 60s, max 75s.
fastcgi_connect_timeout 75s;

# If no responses are read for this length of time, connection is closed. Default 60s
fastcgi_read_timeout 360s;

# Determines whether the connection with a FastCGI server should be closed when a client closes the connection without waiting for a response. Default is off.
fastcgi_ignore_client_abort on;


# https://gist.github.com/magnetikonline/11312172#determine-fastcgi-response-sizes
# http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html

... and valet restart

Sadly the problem still persists and there are no new entries logged.

valet log php-fpm -f

[27-Jul-2023 09:21:00] NOTICE: [pool valet] child 48027 started
[27-Jul-2023 09:21:00] WARNING: [pool valet] child 48025 exited on signal 6 (SIGABRT) after 0.691368 seconds from start
[27-Jul-2023 09:21:00] NOTICE: [pool valet] child 48029 started
[27-Jul-2023 09:21:00] WARNING: [pool valet] child 48027 exited on signal 6 (SIGABRT) after 0.593855 seconds from start
[27-Jul-2023 09:21:00] NOTICE: [pool valet] child 48031 started
[27-Jul-2023 09:21:01] WARNING: [pool valet] child 48029 exited on signal 9 (SIGKILL) after 0.642601 seconds from start
[27-Jul-2023 09:21:01] NOTICE: [pool valet] child 48033 started
[27-Jul-2023 09:21:01] WARNING: [pool valet] child 48031 exited on signal 9 (SIGKILL) after 0.732587 seconds from start
[27-Jul-2023 09:21:01] NOTICE: [pool valet] child 48035 started
[27-Jul-2023 09:21:02] WARNING: [pool valet] child 48033 exited on signal 6 (SIGABRT) after 0.797574 seconds from start
[27-Jul-2023 09:21:02] NOTICE: [pool valet] child 48037 started

valet log nginx -f

2023/07/27 09:20:59 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:20:59 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:00 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:00 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:00 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:01 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:01 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"
2023/07/27 09:21:02 [error] 47904#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/danielthoma/.config/valet/valet.sock:", host: "foo.test"

valet status

Checking status...

Valet status: Healthy

+--------------------------------------+----------+
| Check                                | Success? |
+--------------------------------------+----------+
| Is Valet fully installed?            | Yes      |
| Is Valet config valid?               | Yes      |
| Is Homebrew installed?               | Yes      |
| Is DnsMasq installed?                | Yes      |
| Is Dnsmasq running?                  | Yes      |
| Is Dnsmasq running as root?          | Yes      |
| Is Nginx installed?                  | Yes      |
| Is Nginx running?                    | Yes      |
| Is Nginx running as root?            | Yes      |
| Is PHP installed?                    | Yes      |
| Is linked PHP (php) running?         | Yes      |
| Is linked PHP (php) running as root? | Yes      |
| Is valet.sock present?               | Yes      |
+--------------------------------------+----------+

Versions:

Laravel Valet: 4.1.3
PHP: 8.2.8
nginx: 1.25.1

from valet.

faytranevozter avatar faytranevozter commented on August 15, 2024

im facing the same problem with postgres in db connection. my issue is same as this stackoverflow question

it works on php artisan serve but not in valet

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024

I also have this issue since upgrading brew and valet (PHP 8.2.8, and noticeably OpenSSL 1.1 to 3), but with mongodb instead of postgres. The application works well, until I access a page that uses mongo, then I get the same 502 nginx/fastcgi abort segvault.

php artisan serve also works for me, but not valet.

from valet.

drbyte avatar drbyte commented on August 15, 2024

Does this problem only happen on Ventura?

Screen Shot 2023-07-27 at 11 56 01 AM

from valet.

djfhe avatar djfhe commented on August 15, 2024

i'm on venture:
image

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024

Does this problem only happen on Ventura?

Nope, I'm on Monterey.

from valet.

mattstauffer avatar mattstauffer commented on August 15, 2024

I tried @askdkc's suggestion and it didn't solve the issue, but it seems like that may at least be partially a solution, since there are at least two people who said it fixed it for them.

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024

I tried @askdkc's suggestion and it didn't solve the issue, but it seems like that may at least be partially a solution, since there are at least two people who said it fixed it for them.

It also didn't fix it for me (neither did the OBJC_DISABLE_INITIALIZE_FORK_SAFETY config change)

from valet.

drbyte avatar drbyte commented on August 15, 2024

If the homebrew plist file edit didn't solve it for you, check whether the change is reflected in the /Library/LaunchDaemons version of the file. If not, then manually sudo brew services restart php and check the file again. If that doesn't work, first sudo brew services stop php, and then valet start. That should copy the file from the homebrew master location into the LaunchDaemons dir and include the change when restarting the service.

Hopefully that helps...

from valet.

subdesign avatar subdesign commented on August 15, 2024

Same here. 502 error, "upstream prematurely closed connection while reading response header from upstream" in the nginx error log. I don't use Postgres , and session driver is not database, and has Monterey.
I "mirrored" my projects to a new M1 Pro from my old Macbook 2015, the only difference is the old machine has Valet 3.3.2, the new 4.1.3 .
But, some of my projects are working, the others get 502, but all files, composer and node versions are the same. This is why I guess the new Valet version has strange behaviour.
Next try I'll force 3.3.2 to install and see what happens. What do you think?

from valet.

subdesign avatar subdesign commented on August 15, 2024

So, reverting back to an older Valet version won't solve the problem, since you're probably using recent Homebrew package versions, and downgrading those is actually kinda complicated.

Totally right, nothing changed in a good way after reverting back to 3.3.2.

from valet.

askdkc avatar askdkc commented on August 15, 2024

@mattstauffer @SanderMuller

related with #1433 (comment)

Please make sure you don't have homebrew.mxcl.php.plist in ~/Library/LaunchAgents <- This is inside of your home directory

Only place you want homebrew.mxcl.php.plist to exist is /Library/LaunchDaemons <- This is top level /Library

If you find homebrew.mxcl.php.plist in ~/Library/LaunchAgents, remove it and then reboot your Mac. And try this step again.

#1433 (comment)

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024

@mattstauffer @SanderMuller

related with #1433 (comment)

Please make sure you don't have homebrew.mxcl.php.plist in ~/Library/LaunchAgents <- This is inside of your home directory

Only place you want homebrew.mxcl.php.plist to exist is /Library/LaunchDaemons <- This is top level /Library

If you find homebrew.mxcl.php.plist in ~/Library/LaunchAgents, remove it and then reboot your Mac. And try this step again.

#1433 (comment)

I only have homebrew.mxcl.php.plist in /Library/LaunchDaemons, not in /Library/LaunchAgents or ~/Library/LaunchAgents

from valet.

askdkc avatar askdkc commented on August 15, 2024

@SanderMuller

Interesting. Did you run brew upgrade? Which php version are you using? 8.2.8?

Try directly change /Library/LaunchDaemons/homebrew.mxcl.php.plist then without doing anything, just reboot your Mac.
See how it goes?

from valet.

askdkc avatar askdkc commented on August 15, 2024

@SanderMuller

Oh, I thought you were having trouble with PostgreSQL. My bad.

If it's related with homebrew, you might try adding

<key>EnvironmentVariables</key>
<dict>
    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
    <string>YES</string>
</dict>

to your mongodb start up script.

from valet.

SanderMuller avatar SanderMuller commented on August 15, 2024

@SanderMuller

Oh, I thought you were having trouble with PostgreSQL. My bad.

If it's related with homebrew, you might try adding

<key>EnvironmentVariables</key>
<dict>
    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
    <string>YES</string>
</dict>

to your mongodb start up script.

Thank you for being so helpful!

MongoDB php extensions is installed via PECL, not homebrew (not available via homebrew).
I'm using an external mongo server (Atlas)
Would you have any idea where I would have to add the OBJC_DISABLE_INITIALIZE_FORK_SAFETY env variable in this case?

from valet.

askdkc avatar askdkc commented on August 15, 2024

@SanderMuller

Usually it should be this line in your mongodb plist :

・・・
<key>RunAtLoad</key>
<true/>
   ↑ UNDER THIS LINE
<key>EnvironmentVariables</key>
・・・

from valet.

askdkc avatar askdkc commented on August 15, 2024

Hmm, my PR seems not convincing homebrew maintainers 😕

I’m afraid this problem won’t fix soon. At least we have a work around though.

If someone could help, please leave a comment on the homebrew PR👍

from valet.

drbyte avatar drbyte commented on August 15, 2024

Related: shivammathur/homebrew-php#1862

from valet.

askdkc avatar askdkc commented on August 15, 2024

@sashko-guz

I did manage to reproduce and fix gettext issue by doing like this comment: Homebrew/homebrew-core#137431 (comment)
Could you also test this?

from valet.

stubbo avatar stubbo commented on August 15, 2024

I just build the Mongo extension with OpenSSL and it seems to work fine.
Seems to be an issue with Secure Transport found this log after adding mongodb.debug = stderr to my ini file stream-tls-secure_transport: TRACE > ENTRY: mongoc_stream_tls_secure_transport_new():666

Which version of OpenSSL? Most of the PHP versions currently being reported as troublesome have been compiled with openssl 3, instead of the older soon-to-be-deprecated 1.1

Looks like I built it using 3.1.1_1 and it compiled fine

from valet.

sajaddp avatar sajaddp commented on August 15, 2024

I have the same problem.
What I noticed was that as soon as I updated openssl via brew the problem occurred.
The noteworthy point is that the error does not occur when using ‍sqlite‍, but the error occurs when using pgsql. (I have not tested other databases.)
However, it is certain that my errors started with the openssl update.

  • Valet 4.0.1
  • Php 8.2.8
  • Nginx 1.25.1

from valet.

sajaddp avatar sajaddp commented on August 15, 2024

No new update planned?

from valet.

dbarrerap avatar dbarrerap commented on August 15, 2024

Greetings all.

I'm using Valet 4.1.4 but because of different projects, I'm working with PHP 8.0 (Laravel 7) and 8.2 (Laravel 9). This workaround worked for 8.2, but not for 8.0.

I tried Herd for a while, but Valet is compatible with other project I'm planning on (WordPress), which AFAIK don't seem to work with Herd.

from valet.

suman98 avatar suman98 commented on August 15, 2024

any update
it does not work after restarting my pc
work okey with mysql but when connecting postgressql it show 502 gateway timeout

from valet.

dbarrerap avatar dbarrerap commented on August 15, 2024

any update it does not work after restarting my pc work okey with mysql but when connecting postgressql it show 502 gateway timeout

Perhaps unrelated, but this suggestion in issue #315 helped me. And now it all works, PHP 8.0 and 8.2. It gets some hiccups from now and then, but it works

from valet.

suman98 avatar suman98 commented on August 15, 2024

@dbarrerap I tried this
#1433 (comment)
it fixed my issue now postgres is working on mine laravel valet

from valet.

sulimenko avatar sulimenko commented on August 15, 2024

I encountered the same error, but it's not clear to me why script executes well in the local console.

when querying via valet or pure nginx it terminates php with an error: WARNING: [pool valet] child 42090 exited on signal 6 (SIGABRT) after 62.181861 seconds from start

<?php

$host = '127.0.0.1';
$port = '5432';
$dbname = 'base';
$user = 'user';
$password = 'pass';

try {
    $dsn = "pgsql:host=" . $host . ";port=" . $port . ";dbname=" . $dbname . ";user=" . $user . ";password=" . $password . ";";
    $pdo = new PDO($dsn);

    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $sql = "SELECT * FROM table LIMIT 10";
    $stmt = $pdo->query($sql);

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo "id: " . $row['id'] . ", Name: " . $row['name'] . "<br>";
    }

    $pdo = null;
} catch (PDOException $e) {
    echo "Error PostgreSQL: " . $e->getMessage();
}
?>

If this is a PHP and macOS problem, why does it work fine from the console?

from valet.

drbyte avatar drbyte commented on August 15, 2024

why does it work fine from the console?

PHP has 2 binaries/executables:
The console uses the command-line interface, which uses the php binary/executable.
But nginx, uses php-fpm for all PHP operations.

from valet.

sulimenko avatar sulimenko commented on August 15, 2024

I understand your point, but what prevents PHP developers from taking the PDO internals from cli and replacing them in PHP-FPM.

I also tried to run without PHP-FPM using FastCGI - it doesn't work.

server {
    listen 127.0.0.1:80;
    server_name php.test;

    root /Users/alexey/site/php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    charset utf-8;
    client_max_body_size 128M;

    access_log off;

    location ~.php$ {
      include fastcgi_params;
      fastcgi_pass "unix:/Users/alexey/.config/valet/valet.sock";
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

I changed plist: OBJC_DISABLE_INITIALIZE_FORK_SAFETY = YES
PHP: 7.4.33
Laravel Valet: 4.1.4
nginx: 1.25.2
M1 macOS 12.5 (21G72)
Kernel: Darwin 21.6.0

from valet.

suman98 avatar suman98 commented on August 15, 2024

[10-Sep-2023 17:27:02] WARNING: [pool valet] child 8482 exited on signal 9 (SIGKILL) after 16.588784 seconds from start
[10-Sep-2023 17:27:02] NOTICE: [pool valet] child 8504 started

I am getting this error for laravel valet with postgres
Any solution

from valet.

driesvints avatar driesvints commented on August 15, 2024

Is anyone willing to PR a fix?

from valet.

caturseptian avatar caturseptian commented on August 15, 2024

Homebrew/homebrew-core#137431 (comment)

thanks!

from valet.

rismailov avatar rismailov commented on August 15, 2024

If you're using Homebrew and this solution doesn't fix the issue for you, please make sure you're modifying homebrew.mxcl.php.plist file in the active php directory.

What I mean by that is, in my case, I had the following file structure:
/opt/homebrew/Cellar:
    php/
        8.0/
        8.1/
        8.2/ <----- this is the php version I use, so I figured it's there. but this package is not the active one
        etc...
    [email protected]/
    [email protected]/ <--------- this is the active package and this is where I needed to modify the .plist file

Those extra packages were created when I was trying to switch and link the php versions. As silly as it sounds, I've lost a few hours on this one and hopefully it will help someone.

from valet.

muzidudu avatar muzidudu commented on August 15, 2024

好的伙计们!使用我报告的这些信息,我找到了解决此问题的方法。

(我假设,哟都运行了,php版本是8.2.8)brew upgrade

vi /opt/homebrew/Cellar/php/8.2.8/homebrew.mxcl.php.plist

像这样更改文件的内容: https://gist.github.com/askdkc/28480a0af1301993d92187920abec3bc`homebrew.mxcl.php.plist`

然后运行

valet restart

现在,PostgreSQL一切正常!

thx for ur help

from valet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.