Change 127.0.0.1 to localhost and it should work.
When migrating the DB i can only use: DB_HOST=127.0.0.1
When using the DB (from within the application) I have to switch this to: DB_HOST=localhost
How can I avoid this complication?
I had exactly the same problem, karlonauger.
If you're using Homestead, your DB_HOST should be set to localhost. The reason why in such case artisan (migrate) cannot connect to database is because you are not executing the commands inside your virtual machine.
To do it the right way connect to your vm using:
vagrant ssh
and once logged in, continue as you'd normally.
Hope that helps!
If you set the DB_HOST to the APP_URL then it will always work, on your dev machine and the VM so like this:
APP_URL=http://homestead.app
DB_CONNECTION=mysql
DB_HOST=homestead.app
DB_PORT=3306
DB_DATABASE=#
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=sms DB_USERNAME=root DB_PASSWORD=root
work for me
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community