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" = [email protected] limit
9
  • the default database name is homestead and try running it from the vagrant box (vagrant ssh) Commented Oct 5, 2017 at 9:51
  • I have tried, but still get an error.. It works in mysql, but not in my postgresql @morph Commented Oct 6, 2017 at 1:04
  • are you able to connect to pgsql server via command line or some gui application? Commented Oct 6, 2017 at 9:14
  • I can connect it via cmd, and I can connect via gui application, but when I do select * from users. It will load(non stop)@morph Commented Oct 7, 2017 at 5:43
  • ensure you have latest version of Vagrant, VirtualBox & Homestead. You may need to destroy your box. Could also try creating a fresh laravel project. Commented Oct 9, 2017 at 9:25

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

6 Comments

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
do you also specify the port via command line? try to use 5432 and change localhost to 127.0.0.1
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
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 ?
Don't forget to restart the server everytime you change the .env!
|
1
+50

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.