Error: failed to connect to [localhost:27017] - javascript

When I run node app.js, I get the following error:
Failed to load c++ bson extension, using pure JS version
Express server listening on port 3000
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/Users/me/development/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
at emit (events.js:118:17)
at null.<anonymous> (/Users/me/development/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at emit (events.js:110:17)
at Socket.<anonymous> (/Users/me/developmen/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
at Socket.emit (events.js:107:17)
at net.js:451:14
at process._tickCallback (node.js:355:11)
I'm not sure whether this is localhost problem or an issue with the connection to mongodb. I tried looking at similar questions SO and Github but it didn't help me.

Seems like mongodb server is not running. Check it

Related

ECONNRESET Meteor

I am suddenly getting this error & there is no way I am able to trace the issue, my server keeps crashing again & again, and I haven’t done any changes in months for sure.
events.js:288
throw er; // Unhandled 'error' event
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:205:27)
Emitted 'error' event on Socket instance at:
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read'
}
Anyone facing this issue or have solution to the crash?
I tried to comment as much code as possible to avoid this issue but no luck.
Can anyone help me if this error was faced by anyone?
This problem could be due to your connection,
may be you lost your internet connection or from your server so check your server is that running properly or not

HTTP 6369: SOCKET ERROR: read ECONNRESET - Node server connecting to Filemaker Data API

I have run into this error with my Node server when trying to access a Filemaker Server driven backend both locally and remotely.
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
After trying everything I can find, triple-checking my FMS settings and logs, restarting the server and the machine several times, I cannot figure out what exactly is going wrong and how to solve it.
I have seen some answers to similar questions here on SO, but for the most part they just suggest catching the error in the express route (has not been changed for months and was working fine before the error), which I have done but it just outputs a more verbose version of the main error above:
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/******/Documents/*****/code/******/node_modules/request/request.js:751:32)
THE ERR : Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
---------------------------------------------
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/********/Documents/*******/code/******/node_modules/request/request.js:751:32) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall:'read'
}
Also, my Node API in general had already been operating more or less seamlessly for several months of development before this problem arose. One thing was that changed on my machine was my company adding ScaleFusion device management software. I mentioned before the install that it could cause problems with the Node server API calls and the error only happened after ScaleFusion was added. Maybe it is possible the software is causing this problem?
Have been trying to find a fix for a couple of days now but running out of leads on it. If anyone can help out I'd really appreciate it. Thanks in advance for any suggestions.

Mongodb events.js:85

I am working on this project since long. I am facing some problem which I am unable to solve after trying really hard. I would really appreciate if you guys can help me. I am trying to connect to mongodb database using node.js but whenever I start server I get following error. And I have no idea how to solve that error.
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
The magic happens on port 8080
Connected correctly to server
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [undefined:27017]
at null.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:556:74)
at emit (events.js:118:17)
at null.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
at emit (events.js:110:17)
at Socket.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
at Socket.emit (events.js:107:17)
at net.js:950:16
at process._tickCallback (node.js:355:11)
Thank you for your time and consideration
Are you sure you are up and running mongodb locally in the system ?
To map local path to mongodb try the following command
[location of mongodb]/bin/ mongod --dbpath "specify location of database"
Do you write you code like below?
mongoose.connect(configDB.url); // connect to database
I guess you did't set your configDB.url .
set it with your db url like 'localhost:27017/myDatabase'

Repeated errors will cause Forever to stop restarting node.js app

I am running a node.js server as a backend for a client side Javascript application and we are using Forever to launch the node.js app.
A bug has been discovered in the client code that provides an incorrect path when trying to open a file (because of case insensitivity in our current server). The error is not properly handled and this causes node.js crash. The first few times this occurs Forever sucessfully relaunched the app but after repeatedly triggering the error Forever will fail to bring the app back up and we get a 502 bad gateway error when trying to goto any of the server pages.
Here is the unhandled error:
Error: ENOENT, no such file or directory 'public/projects/testHoc7/hocProject121/agents/agent1/index.agent'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.editAgentXML [as edit_agent_XML] (/srv/AgentCubesOnline/project.js:699:5)
at /srv/AgentCubesOnline/project.js:313:30
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/collection/query.js:159:5
at Cursor.nextObject (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:742:5)
at commandHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:716:14)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/db.js:1847:9
at Server.Base._callHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/server.js:478:18
error: Forever detected script exited with code: 8
error: Script restart attempt #8
/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:245
throw message;
and here is the log message we get when Forever fails to restart the app:
Error: ENOENT, no such file or directory 'public/projects/testHoc7/hocProject121/agents/agent1/index.agent'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.editAgentXML [as edit_agent_XML] (/srv/AgentCubesOnline/project.js:699:5)
at /srv/AgentCubesOnline/project.js:313:30
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/collection/query.js:159:5
at Cursor.nextObject (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:742:5)
at commandHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:716:14)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/db.js:1847:9
at Server.Base._callHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/server.js:478:18
error: Forever detected script exited with code: 8
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/eventemitter2.js:283
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:332:26
at process._tickCallback (node.js:419:13)
We will of course fix the bug and add proper error handling but I am currently more interested in finding out how to prevent Forever from failing. What could cause Forever to stop bringing node.js back?

Occassional ECONNREFUSED errors

I just got started with nodejs and using it to create a server. Clients connect to it using socket.io, receive jobs to proceess, and send the results back to the nodejs server.
However the server will crash occassionally with the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: connect ECONNREFUSED
at errnoException (net.js:614:11)
at Object.afterConnect [as oncomplete] (net.js:605:18)
I have no idea what is causing this.
ECONNREFUSED means you tried to make a connection to another machine but your connection was refused - either no one was listening or a firewall blocked you.
I have seen this using http, but I think it could also happen using straight sockets.
You are probably struggling with node.js dying whenever the server you are calling refuses to connect. Try this:
process.on('uncaughtException', function (err) {
console.log(err);
});
It will just log the errors and keep your service up and running.

Categories

Resources