Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php artisan migrate throws received invalid response to SSL negotiation

I have a laravel app on nginx with postresql

php artisan migrate 

throws error:

In Connection.php line 671:
                                                                                                                                               
  SQLSTATE[08006] [7] received invalid response to SSL negotiation: b (SQL: select * from information_schema.tables where table_schema = publ  
  ic and table_name = migrations and table_type = 'BASE TABLE')                                                                                
                                                                                                                                               

In Connector.php line 70:
                                                                       
  SQLSTATE[08006] [7] received invalid response to SSL negotiation: b 


                                                                   

FILES:

.env

...

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=secretdbname
DB_USERNAME=secretusername
DB_PASSWORD=secretpassword 

...

postresql.conf ...

port = 5432 

...

in php.ini enabled:

pgsql
pdo_pgsql
mbstring

php -m

...

mbstring
openssl
PDO
pdo_mysql
pdo_pgsql
pgsql

...

Appropriate db exists, user exists and has got all the privileges. Postgres service is active. DB and app are located on the same server.

What I have tried:

  • setting up a different port in both .env and postgres.conf
  • tested with a different db, user and password
  • restarted postresql
  • in tinker DB::connection()->getPdo(); throws the same error
  • in DB_HOST tried 127.0.0.1. instead of localhost
  • in config/database.php i tried setting 'sslmode' to 'disable'

I have SSL certificate with certbot.

I would appreciate some hint on how to solve the above error.

like image 885
Arson Avatar asked Dec 06 '25 08:12

Arson


1 Answers

I got the same error today with the Laravel 9.

The solution was to make sure the Postgress DB_Port inside .env is pointing to 5432.

Hope it will help others.

like image 68
Basiir - MY Avatar answered Dec 07 '25 22:12

Basiir - MY



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!