Home » Php » php – How to use postgreSQL in Laravel Homestead

php – How to use postgreSQL in Laravel Homestead

Posted by: admin July 12, 2020 Leave a comment

Questions:

I can do migration to my homestead.
this is my .env

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=54320
DB_DATABASE=intern
DB_USERNAME=homestead
DB_PASSWORD=secret

And I make a new server in my postgreSQL with

server name = Homestead,  
username = homestead,  
password = secret.  

then, I did migration and all the table created into my database(server=homestead)
The problem is, when I want to do login in my site. It occurs an error:

SQLSTATE[08006] [7] could not connect to server: Connection refused↵  
Is the server running on host "localhost" (::1) and accepting↵  
TCP/IP connections on port 54320?↵could not connect to server: Connection refused↵  
Is the server running on host "localhost" (127.0.0.1) and accepting↵  
TCP/IP connections on port 54320? (SQL: select * from "users" where "email" = [email protected] limit
How to&Answers:

You have an extra 0 at the end of your port. Change DB_PORT=54320 to DB_PORT=5432

Answer:

try to access your homestead with ssh.

i think u already change the password from the inside

from laravel documentation i think that config should work

or try this command after u change the config

php artisan config:cache and php artisan cache:clear

https://laravel.com/docs/5.6/homestead#connecting-to-databases