Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu[16.04.2 64bits] PHP[7.0.15] timeout on connect SQL Server Windows Instance #340

Closed
Rafabin opened this issue Mar 27, 2017 · 3 comments

Comments

@Rafabin
Copy link

Rafabin commented Mar 27, 2017

My Ubuntu Server (192.168.10.1)
16.04.2 (64 Bits)
-Microsoft SQL Server vNext (CTP1.4) - 14.0.405.198 (X64)
-default instance instaled guide
-db LEGACY

My Windows (192.168.0.50)
-Microsoft SQL Server 2014 Express 2014.120.2269.0
-Instance 192.168.0.50\LEGACY
-db LEGACY
-Management Studio 2016
-Firewall Off
-No Antivirus

Issue.
-The php7.0 (ubuntu) connects to the local instance (ubuntu) but does not connect to the remote instance (windows)
-The management studio (windows) successfully connects to the ubuntu and windows instance

Error.
(Ubuntu)-> sqlcmd -S 192.168.0.50\LEGACY -U sa -P xxxxxxxx -Q "USE LEGACY;"

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections.

(Ubuntu)-> sqlcmd -S localhost -U sa -P xxxxxxxx -Q "USE LEGACY;"
OK Connected!

(Ubuntu) - PHP
-localhost sql server instance 'Connected'!
-windows sql server instance Timeout! =/
[0] => HYT00
[SQLSTATE] => HYT00
[1] => 0
[code] => 0
[2] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
[message] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired

[0] => 08001
[SQLSTATE] => 08001
[1] => -1
[code] => -1
[2] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
[message] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].

$serverName = "localhost";
$connectionOptions = array(
                "Database" => "LEGACY",
                "UID" => "sa",
                "PWD" => "xxxxxxxx"
);
            //Establishes the connection
            $conn = sqlsrv_connect($serverName, $connectionOptions);

            if ($conn == FALSE)
                die(print_r(sqlsrv_errors()));
            else
                echo 'Connected!';

sem titulo

@Rafabin Rafabin changed the title Ubuntu timeout on connect SQL Server Windows Instance Ubuntu[16.04.2 64bits] PHP[7.0.15] timeout on connect SQL Server Windows Instance Mar 27, 2017
@yukiwongky
Copy link
Contributor

yukiwongky commented Mar 27, 2017

@Rafabin, to connect to a named instance, you need to provide the port number. Please see here.

Other users also experienced this Login timeout expired issue due to port number, firewall, or odbc config. Please see #190 for other possible solutions.

@meet-bhagdev
Copy link
Contributor

@Rafabin: Does @v-kaywon's recommendation help?

@meet-bhagdev
Copy link
Contributor

@Rafabin Closing due to in-activity. Feel free to re-open if you still need help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants