Show your docker-compose.yml please
Cannot connect to DB?
Hello, back to playing around in Laravel after a long break. I've gone down the docker route using WSL on windows running ubuntu this time. It's all quite fancy.
While my .env fine has the MySQL host set to 127.0.0.1 I can connect to the MySQL container in the terminal, and my DB program and using artisan migrate and tinker all work. however, when I try to connect to the DB in the browser through I route I get the following error.
SQLSTATE[HY000] [2002] Connection refused
I read online you can change the host to the container name but when i do this i get the following error in the browser and also all functions that were working in the command line stop working.
browser error:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql-1 failed: Temporary failure in name resolution
command line error (pa migrate)
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql-1 failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations and table_type = 'BASE TABLE')
Not sure what else to try. Pretty new to this whole docker thing and ive tried everything google had to offer.
My .env file if usefull.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=sail
DB_PASSWORD=password
Any help would be awesome, Thanks!
@Makka if you are using sail, you can run sail artisan migrate for instance
Please or to participate in this conversation.