question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection Error: Connection is Closed

See original GitHub issue

Hi…

I’m able to access my MSSQL from MSQL Studio. defined my index.js file as below, but it keeps give me this error:

{ [ConnectionError: Connection is closed.] name: ‘ConnectionError’, message: ‘Connection is closed.’, code: ‘ECONNCLOSED’}

what wrong I’m doing, if below is my code, thanks

 var sql = require('mssql'); 
 var config = { user: 'sa', password: 'bk123', server: 'HASN-BK\\SQLEXPRESS', database: 'BK',
stream: true }

  sql.connect(config, function(err) {
 var request = new sql.Request();
 request.stream = true; 
request.query('SELECT * from emp');

request.on('recordset', function(columns) {
    console.log(columns);
    // Emitted once for each recordset in a query
});

request.on('row', function(row) {
    console.log(row);
    // Emitted for each row in a recordset
});

request.on('error', function(err) {
    console.log(err);
    // May be emitted multiple times
});

request.on('done', function(returnValue) {
    // Always emitted as the last one
});

});

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:40

github_iconTop GitHub Comments

6reactions
benororcommented, May 19, 2015

I have the same issue when I run 2 or more queries one right after the other

Microsoft SQL Server 2012 - 11.0.5058.0 (X64) May 14 2014 18:34:29 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
5reactions
guillaumedardennecommented, May 20, 2015

Worked fine for me, better use a global connection rather connecting to the databse each time you have to make a request to avoid the ‘Connection is closed Error’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Error Connection Closed Error in Google Chrome?
How to Fix Connection Closed Error? · Check your internet connection · Check the firewall connection · Disable proxy server and VPN ·...
Read more >
How To Fix "ERR_CONNECTION_CLOSED" in Chrome (13 ...
The ERR_CONNECTION_CLOSED message is an error that you might see in Chrome when you try to access a website. It means that something's...
Read more >
How to Fix ERR Connection Closed Error in Chrome Browser
ERR Connection Closed Error in Chrome Browser · 1. Clear Browsing Data · 2. Disable Proxy Server · 3. Flush DNS and Reset...
Read more >
ERR_CONNECTION_CLOSED: How to fix the connection error
How to fix the “ERR_CONNECTION_CLOSED” error · Solution 1: Check internet connection and restart router if necessary · Solution 2: Reset network ...
Read more >
Node js: mssql [ConnectionError: Connection is closed.] name
but when savedquery is calling then connection close error occurs. each method code is similar to savedquery method (copy pasted code only queries...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found