SQLSTATE[01002] Adaptive Server connection failed (severity 9)

SQLSTATE[01002] Adaptive Server connection failed (severity 9)

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

SQLSTATE[01002] Adaptive Server connection failed (severity 9)

When a PHP application running on a new server throws SQLSTATE[01002] Adaptive Server connection failed, it signals that the underlying database driver cannot establish a handshake with Microsoft Azure SQL Database. You might assume this is a network issue, especially if you've verified connectivity via telnet to port 1433 and confirmed your IP address has not changed. However, the error code itself points specifically to a failure in the protocol negotiation or authentication exchange, not merely a dropped packet.

Your stack trace shows the use of the dblib driver with the standard DSN string: dblib:host=$hostname;dbname=$dbname. While this works on your legacy server, the new environment runs PHP 5.6 with the php5.6-pdo-dblib package installed via apt-get. The crucial detail often missed in these scenarios is that the Azure SQL Database service has largely deprecated support for the older DB-LIB protocol used by Sybase and early versions of Azure SQL, replacing it with TDS (Tabular Data Stream) or requiring specific FreeTDS configurations.

The error "Adaptive Server connection failed" usually implies that the server accepted the TCP connection but rejected the client's request to initiate a session using the expected dialect. On Azure, this often happens when the client attempts to use the legacy DB-LIB protocol without explicitly specifying the required TDS version or when the FreeTDS library on the new server defaults to an incompatible configuration.

To resolve this, you must ensure the PDO connection string explicitly requests the TDS driver and specifies a compatible version. Instead of relying solely on dblib, which may default to legacy behavior, you should try switching the driver in your code to use the FreeTDS library directly through the pdo_dblib extension with specific parameters.

Here is an updated connection string that forces the TDS protocol and disables the legacy DB-LIB mode:

$dsn = "dblib:host=secrets.database.windows.net;dbname=secrets;charset=utf8";
$options = [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_PERSISTENT => false
];

try {
    $dbh = new PDO($dsn, "secrets", "secrets", $options);
} catch (PDOException $e) {
    // Log full error for debugging
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}

If the above does not resolve the issue, you may need to install FreeTDS on your new server and switch to using the sybase or tsql driver if available, or explicitly configure the FreeTDS .conf file (typically located at /etc/freetds/freetds.conf) to match Azure's requirements. The freetds.conf should specify client = TDS73 or higher to ensure compatibility with modern Azure endpoints.

Another common pitfall is the use of plaintext passwords over an unencrypted connection. Azure SQL Database now enforces encrypted connections by default, and legacy drivers that do not support TLS may fail with a generic connection error. Ensure your environment supports SSL/TLS for database connections, either by configuring the driver to use encryption or by using a connection string that includes Encrypt=yes.

$dsn = "dblib:host=secrets.database.windows.net;dbname=secrets;charset=utf8;Encrypt=yes";

Finally, consider whether your application can migrate from PHP 5.6 to a newer major version. PHP 5.6 reached end-of-life in January 2019 and no longer receives security updates or driver improvements. Many modern PDO drivers and database extensions have dropped support for legacy protocols on older PHP versions, which could explain why the old server works while the new one fails.

In production environments using Laravel or similar frameworks, you might find that configuring the connection pool with proper SSL settings and using environment variables for credentials is more secure and maintainable than hardcoding them in scripts.

Our network