PHP 7.0.4 , x86
Php_pdo_sqlsrv_7_ts_x86.dll driver

On the local machine connects

try { $db = new PDO('sqlsrv:Server=localhost\SQLEXPRESS;Database=db', 'sa', '1111'); } catch (Exception $e) { echo $e->getMessage(); } 

But no external address

 sqlsrv:Server = IP; // ни так sqlsrv:Server = IP,1433 // ни так sqlsrv:Server = IP\SQLEXPRESS,1433 // и ни так 

SQLSTATE [08001]: [Microsoft] [ODBC Driver 13 for SQL Server] TCP Provider: Connection not established because destination computer rejected connection request.


Through SQL Server Management Studio connects to SRV \ SQLEXPRESS


The SQL Server Configuration Manager in the Native Client configuration shows the default port 1433 that is forwarded to the router


netstat does not know about 1433

  • Are remote connections allowed on the server? a mistake something like just talking about it - Anatol
  • @Anatol how to resolve? In Management Studio server properties is permission for remote connections to this server . There are no permissions in the database properties - Mr. Black
  • OS settings, see, firewall, etc. - Anatol
  • @Anatol, FV is disabled - Mr. Black
  • I understand the problem is that the remote connection for sa is not configured. Google in this direction, I'm not sure how this is configured in mssql. - user3416803

1 answer 1

SQL Server Configuration ManagerProtocols for SQLEXPRESS

Set TCP / IP to Enabled
Tab IPs where IPAll set TCP port 1433
Restart service

TCP port

Oh this divine access

 0.0.0.0:1433 SRV:0 LISTENING 
  • I went only to the ip address, port 1433 is standard, you do not need to specify PDO('sqlsrv:Server=IP;Database=db', 'sa', '1111'); - Mr. Black