0

Why I can't connect to Homestead mysql when I use artisan serve build in server? Host, port is configured in .env to point at Homestead database.

Why I want artisan serve instead of Homestead server? I'm making Nuxt app with hotreload and I want to test in while on localhost:8000 port.

Right now I'm getting "SQLSTATE[HY000] [2002] Connection refused".

Oh after npm build on Homestead server connection to database working great... so it's not credentials problem.

Krystus
  • 285
  • 3
  • 4
  • 14
  • What's the database URL for your connection? You have to set up your laravel project to connect to the virtual machine IP. [This should get you on the right path](https://stackoverflow.com/questions/38643837/homestead-connecting-to-my-database#answer-38645321) – DevK Mar 25 '18 at 02:06
  • @devk standard credentials for homested... DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=my_database_name DB_USERNAME=homestead DB_PASSWORD=secret – Krystus Mar 25 '18 at 02:11
  • You need to correctly configure `DB_HOST` to connect to your VM. 127.0.0.1 points to your main OS. Check the link that I posted, seems pretty straight forward. – DevK Mar 25 '18 at 02:22
  • @devk you are right. 192.168.10.10 instead of 127.0.0.1. Thanks! – Krystus Mar 25 '18 at 02:30

1 Answers1

1

Virtual machine IP... 192.168.10.10 instead of my main OS IP 127.0.0.1. Solved. Thanks to @devk.

Krystus
  • 285
  • 3
  • 4
  • 14