I am trying to create a new item via postman to my laravel app ran in docker. The docker containers are auto-generated via ddev which provides a development environment and ran using WSL2 Ubuntu 18.04. So here is the catch, I can "php artisan migrate" just fine I can even "php artisan tinker" and create one just fine but when sending request via postman from my host machine I get this error.
Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from
users
whereid
= 1) in file /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 671
I had solved this issue yesterday with this https://www.craigforrester.com/posts/windows-subsystem-for-linux-disable-ipv6-for-apt/ but tried it when I got this error again today and no luck.
Things I've Tried:
- Setting DB_HOST to 127.0.0.1, wsl_ip, docker_gateway_ip, docker_mysql_ip, localhost, mysql. And actually I get the same error on all of them except localhost, which makes sense.
- Forcing ipv4 https://www.craigforrester.com/posts/windows-subsystem-for-linux-disable-ipv6-for-apt/
- Changing gai.conf settings https://www.reddit.com/r/bashonubuntuonwindows/comments/7u1le5/disable_ipv6_or_prefer_ipv4_first/
- Changing grub config https://askubuntu.com/questions/1046057/disabling-ipv6-in-ubuntu-server-18-04
What I Think It Is: I am 99% certain this is not a credentials issue and more so a routing issue, cause like I said in the first paragraph I can migrate and create from the WSL Ubuntu. I think the routing issue is either from my host to the WSL or from WSL to mysql. But then again my request seems to be going through otherwise I wouldve got some kind of PHP connection error and not a MySQL connection error