I am trying to connect to a SQL Server instance from a Node.js application using Windows Authentication, but I’m encountering a connection timeout error.
SQL Server Version: SQL Server 2019
Port: 1433
And TCP enabled on Server Configuration Manager enter image description here.
const sql = require('mssql');
const config = {
server: "D15\SQLEXPRESS",
database: "DBToDo",
port: 1433,
options: {
encrypt: false,
trustServerCertificate: true,
connectTimeout: 30000 // 30 seconds
},
authentication: {
type: "default",
options: {
trustedConnection: true // Using Windows Authentication
}
}
};
sql.connect(config, err => {
if (err) {
console.error('Database connection error:', err);
} else {
console.log('Successfully connected to the database!');
}
});
2