I'm trying to connect to a SQL Server instance but the wrong port is being defined when I attempt to connect.
Unable to connect to the database: { SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
at Handshake._callback (C:\test\ExpressGeneric\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:80:20)
at Handshake.Sequence.end (C:\test\ExpressGeneric\node_modules\mysql\lib\protocol\sequences\Sequence.js:88:24)
at Protocol.handleNetworkError (C:\test\ExpressGeneric\node_modules\mysql\lib\protocol\Protocol.js:363:14)
at Connection._handleNetworkError (C:\test\ExpressGeneric\node_modules\mysql\lib\Connection.js:428:18) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1277:8) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) name: 'SequelizeConnectionRefusedError', message: 'connect ECONNREFUSED 127.0.0.1:3306',
I have no idea why this is happening.
Here are my configuration settings. I only changed the pass and db for this post, I am using the correct credentials when connecting.
config.sql = {
host: 'sql2012dev',
database: 'db',
user: 'sa',
password: 'pass'
}
And here is my connection.
const sequelize = new Sequelize(config.sql.database, config.sql.user, config.sql.password, {
host: config.sql.host,
dialect: 'mssql',
port: '1433',
driver: 'tedious',
dialectOptions:{
instanceName: MSSQLSERVER
},
define: {
timestamps: false
},
pool: {
max: 5,
min: 0,
idle: 10000
},
})
I'm able to connect to it remotely just fine using the management studio. Named Pipes and SQL Browser is enabled.
I also had to run npm mysql just to get the app to start.
Here are my dependencies just in case
"dependencies": {
"async": "2.1.5",
"body-parser": "1.17.1",
"client-sessions": "0.7.0",
"cookie-parser": "1.4.3",
"crypto": "0.0.3",
"debug": "2.6.2",
"ejs": "2.5.6",
"express": "4.15.2",
"helmet": "3.5.0",
"jquery": "3.1.1",
"moment": "2.17.1",
"morgan": "1.8.1",
"mssql": "^4.0.4",
"nsp": "2.6.3",
"sendgrid": "4.8.0",
"sequelize": "^3.14.1",
"tedious": "^2.0.0"
}
}