My Laravel 5 has run OK until the database was configured, then found this error:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Doing some research it seems that I configured MySQL access too late, so I should restart the server in order to get the correct environment variables. Well, I'm using Dreamhost's shared server and I just can't do that.
How should I fix this issue?
Thanks
In config/database.php
I changed the default DB connection from mysql to sqlite. I deleted the .env
file (actually renamed it) and created the sqlite file with touch storage/database.sqlite
. The migration worked with sqlite.
Then I switched back the config/database.php
default DB connection to mysql and recovered the .env
file. The migration worked with mysql.
It doesn't make sense I guess. Maybe was something serverside.