I have built a web application in Laravel 8+, locally this application has no issue. After deploying on the Plesk Server (Shared Hosting, Windows Server) having a database connection error.
What I have tried
Connection details:
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
#DB_HOST=localhost -- also tried
#DB_HOST=localhostMSSQLSERVER2017 -- also tried
#DB_HOST=.MSSQLSERVER2017 -- also tried
#DB_HOST=127.0.0.1MSSQLSERVER2017 -- also tried
DB_PORT=1433
DB_DATABASE=serverDbName
DB_USERNAME=serverDbUserName
DB_PASSWORD=serverDbPassword
My database config
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
The error looked like
IlluminateDatabaseQueryException
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: No connection
could be made because the target machine actively refused it. (SQL: select * from
[table_name] where [status] = 1)
1