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

RyanNixon's avatar

Laravel Connection To Sql Server 2012

I am trying to connect my laravel application to sql server 2012 but it gives this error : SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it. (SQL: select * from ADM_Users)

following is my .env file code

DB_CONNECTION=sqlsrv DB_HOST=LAPTOP-L8COSQBB DB_PORT=1433 DB_DATABASE=NJIISO DB_USERNAME=sa DB_PASSWORD=admin123

0 likes
3 replies
claydog's avatar

what does your server php info come back with - is pdo_sqlsrv installed and active?

RyanNixon's avatar

yes pdo is installed .the issue is resolved i changed the connection string as follows

DB_CONNECTION=sqlsrv DB_HOST=LAPTOP-L8COSQBB DB_PORT= DB_DATABASE=NJIISO DB_USERNAME= DB_PASSWORD=

but I think this above connection is through windows authentication when I give db_port ,username and password of sq server authentication it gives below error

SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it.

Please or to participate in this conversation.