8

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" = user@gmail.com limit
Ashutosh Sharma
  • 434
  • 1
  • 9
  • 20
Jems
  • 1,666
  • 4
  • 20
  • 50

2 Answers2

5

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

hutch
  • 163
  • 3
  • 7
  • I ever tried it, but same.. I think that every homestead should add `0` in the last of port.. like mysql `3306` to `33060` and psql `5432` to `54320` – Jems Mar 13 '18 at 09:48
  • do you also specify the port via command line? try to use `5432` and change `localhost` to `127.0.0.1` – Razor May 02 '18 at 19:02
  • I have tried it,, if I am using port 5432.. it works, because it does not using homestead.. I have seen the documentation that there is written to use 54320 @Razor – Jems May 03 '18 at 02:06
  • 2
    you can use both 5432 and 54320, it just depends on your current machine. If you're in the `guest` machine (homestead) you should use the port 5432, if you're in the `host` machine, you should use 54320, otherwise it won't work. Laravel uses the default port 5432 because it's running - by default - inside the guest machine, I'm pretty sure you have to keep it to 5432. Did you try to change `DB_HOST` to `127.0.0.1` ? – Razor May 03 '18 at 14:36
  • Don't forget to restart the server everytime you change the `.env`! – Bálint Budavölgyi May 04 '18 at 08:11
  • I have restarted, but the result is same – Jems May 04 '18 at 13:01
1

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

Kira Katou
  • 158
  • 2
  • 2
  • 16