Connect Laravel application on WSL2 with database on Windows

Asked

Viewed 12 times

0

I have a portable application using WSL2 that runs normally. I had a recent problem when I needed to connect this application with the database that is installed on Windows. I tried to connect several times and always returns the following error:

sqLSTATE[HY000] [2002] Connection refused

I believe that the problem is not in the credentials, as it is in the file . env below:

(the last 3 lines are confidential :D)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=banco
DB_USERNAME=usuario
DB_PASSWORD=senha

I am using Mysql Workbench to access the database data and it is working properly. The same happens with the Windows application, which works correctly except for this connection that database on Windows. That is, the applications work properly, it seems that they are just not able to talk.

How do I make this Laravel application in WSL2 communicate with the Mysql that was installed on Windows?

  • Are settings not cached with other data? The port that Mysql is configured in Windows is this (3306) standard same?

  • Says Marcos, regarding the port of Mysql is this! I’ll see this issue of cache, to see if is the problem here

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.