0

I am working on a site written in PHP (running on a Windows Server under Apache) with MS SQL Server 2005 as database (on another Windows Server).

This error occurs sporadically when running sqlsrv_connect:

Sql State: 08001
Code:      53
Message:   [Microsoft][SQL Server Native Client 10.0]
           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. For more information see SQL 
           Server Books Online.

I have gone over some of the many discussions where others have experienced this error, but most of them relate to basic errors in the setup that would cause the database to be completely unreachable. (As mentioned above - the issue is sporadic.)

Another two possible sources of the error that I have eliminated is DNS - I am using the IP address of the server in the connection string, and it isn't any obvious overloading of the server. It has plenty of available resources and the Activity Monitor doesn't show any overly expensive queries running or long running background jobs.

Here is the code where the error occurs:

    $conn = sqlsrv_connect(
        "[snip ip number of server]",
        array(
            'Database' => '[snip database name]',
            'LoginTimeout' => 5,
            'CharacterSet' => 'UTF-8',
            'UID'=>'[snip user name]',
            'PWD'=>'[snip password]'
        )
    );
    $res = array();
    $status = array();
    /* check for connection errors */
    if($debug) {
        if( !$conn ) {
            if( ($errors = sqlsrv_errors() ) != null)
                ...error handling here...

The code above wasn't written by me - I am generally not really happy with the way it has been written.

The code calls sqlsrv_connect every time it needs to send a query to the database. Has anybody experienced that this (bad) practise could be the cause of the error above?

If this isn't the case, is there any other suggestions wrt. the cause of this problem?

1
  • I have just read up on connection pooling. Could the cause be that the connection pool is exhausted?
    – mzedeler
    Commented Jun 14, 2013 at 13:22

1 Answer 1

0

The error stopped appearing after a restart of our SQL Server. I am flagging this as too localized.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.