Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

StingZW's avatar

Laravel application on WSL not connecting to host Microsoft SQL Server

I am trying to connect to a Microsoft SQL Server running on the Windows Host from my Laravel application on WSL2. I have installed the drivers for PHP and SQL Server on WSL2, but I get the following error on trying to access the database:

SQLSTATE[HYT00]: [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (Connection: sqlsrv, SQL: select top 1 1 [exists] from [users] where [email] =*****

My .env file configuration is as follows:

DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=services
DB_USERNAME=*********
DB_PASSWORD=**********

I have masked username and password. I suspect the issue is to do with IP addresses.

0 likes
0 replies

Please or to participate in this conversation.