HELP: Unable to connect to SQL Server running locally
See original GitHub issueI am at a loss trying to get connected to a local SQL 2019 Server. Below are my settings and what I have tried / turned on. I can connect to the DB through SMSS via locahost.
What am I doing wrong?
- TCP/IP is enabled
- SQL Server and Windows Authentication mode is on
- TCP Port 1433 and TCP Dynamic Port is Blank
- Named Pipes is enabled
- SQL Server is running
- SQL Browser is running
- SQL Server Agent is running
Error: ConnectionError: Failed to connect to localhost:1433 - Could not connect (sequence)
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config = {
server: 'localhost',
authentication: {
type: 'default',
options: {
userName: 'UN',
password: 'PW'
}
},
options: {
database: 'School',
port: 1433
}
};
const connection = new Connection(config);
connection.on('connect', (err) => {
if (err) {
console.log('Connection Failed', err);
throw err;
}
executeStatement();
});
connection.connect();
function executeStatement() {
const request = new Request('select * from Course', (err, rowCount) => {
if (err) {
throw err;
}
console.log('DONE!');
connection.close();
});
// Emits a 'DoneInProc' event when completed.
request.on('row', (columns) => {
columns.forEach((column) => {
if (column.value === null) {
console.log('NULL');
} else {
console.log(column.value);
}
});
});
request.on('done', (rowCount) => {
console.log('Done is called!');
});
request.on('doneInProc', (rowCount, more) => {
console.log(rowCount + ' rows returned');
});
// In SQL Server 2000 you may need: connection.execSqlBatch(request);
connection.execSql(request);
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Unable to connect to SQL Server '(local)'. The step failed.
Hi. i am getting below error , in sql Agent 2008(R2) RTM one of my job. if i run manually it getting succeed....
Read more >Resolving could not open a connection to SQL Server errors
Step 1 - Check that you can ping the SQL Server box · Step 2 - Check that the SQL Services are running...
Read more >Can't connect to localhost on SQL Server Express 2012 / 2016
You need to verify that the SQL Server service is running. You can do this by going to Start > Control Panel >...
Read more >sql server 2008 r2 - Cannot connect to my local instance
Go to SQL Server Configuration Manager. Start->all program->SQL Server 2008 R2->Configuration Tools->SQL Server Configuration Manager. Explore "SQL Server ...
Read more >SQL Server Management Studio unable to connect to local ...
The solution was to open SQL Server Configuration Manager, open SQL Server Network Configuration and click on Protocols for SQLEXPRESS2008 (this ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Btw I would recommend looking into setting up volume mounts and database backups with docker, so that if the docker instance stops or needs to be restarted, you won’t lose your data
I can even connect to the docker instance through SSMS. That’s great!
Yes, close the issue I will use the docker image. Thank you for all of your help and guidance.