A timeout before a stored procedure starts is usually a connection-discovery problem, not a slow procedure. SQL Server Express commonly uses a named instance and a dynamic TCP port, so make the network destination explicit first.
Last updated: October 16, 2026.
const sql = require('mssql');
async function run() {
const pool = await sql.connect({
server: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
options: { encrypt: true, trustServerCertificate: false },
connectionTimeout: 15000,
requestTimeout: 30000
});
const result = await pool.request().execute('dbo.GetOrders');
return result;
}
run().catch(console.error);Configure SQL Server to listen on a fixed TCP port and place that port in DB_PORT. Do not add instanceName when you already supply a port.
Prove the connection path first
Connect in SSMS using the same host and port, for example DBHOST,1433. Confirm the actual instance with SELECT @@SERVERNAME, SERVERPROPERTY('InstanceName'). In SQL Server Configuration Manager, enable TCP/IP for the intended instance, assign a fixed port, restart the Database Engine, and allow that inbound TCP port through the firewall.
Microsoft explains that named instances often depend on SQL Server Browser to translate an instance name into a port. The node-mssql documentation likewise notes that options.instanceName requires Browser service access over UDP 1434. An explicit port avoids that discovery step.
Identify which timeout failed
connectionTimeout covers opening the database connection. requestTimeout covers the command after a connection exists. Log the original error code and timing without logging credentials. If the pool opens but execute() times out, run the procedure with the same parameters in SSMS and inspect blocking, execution plans, and parameter handling.
Keep encryption enabled. For development with a self-signed certificate, solve certificate trust deliberately rather than leaving trustServerCertificate enabled in production. Continue with verifying the SQL Server instance, encrypted SQL Server connections, and separating database timeout types.