connection fail to connect mongodb in node application - node.js

I have an error while starting up server with node server.js. The error details are here:
path.existsSync is now called `fs.existsSync`.
info - socket.io started
[Thu, 02 Aug 2012 00:58:27 GMT] INFO Tower development server listening on port 3000
[Error: Target script does not exist: node_modules/design.io/bin/design.io]
/Users/Drew/test/desert-level-pets/node_modules/tower/lib/tower/server/store/mongodb/database.js:39
throw error;
^
Error: failed to connect to [127.0.0.1:27017]
at Server.connect.connectionPool.on.server._serverState (/Users/Drew/test/desert-level-pets/node_modules/mongodb/lib/mongodb/connection/server.js:473:73)
at EventEmitter.emit (events.js:115:20)
at connection.on._self._poolState (/Users/Drew/test/desert-level-pets/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:92:15)
at EventEmitter.emit (events.js:91:17)
at Socket.errorHandler (/Users/Drew/test/desert-level-pets/node_modules/mongodb/lib/mongodb/connection/connection.js:387:10)
at Socket.EventEmitter.emit (events.js:88:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9
Can anyone can help me to solve it?
Thanks,

You'll need to make sure you have an instance of mongodb up and running. Also, did you run "npm install" in the directory your attempting to run "tower server" in to install design.io and all the other packages tower needs? Looks like that's part of the problem.

Related

MongoDB error while installing Rocket.chat in CentOS 8 server with Apache

I am following this tutorial to install a Rocket.chat server in CentOS:
https://hostpresto.com/community/tutorials/how-to-install-rocket-chat-server-on-centos-7/
I am new to mongodb and node.js so I am not very familiar with how all this works
At the moment I am looking for something simple that just works
When I reach the step where it says to execute
node main.js
I get the following error:
[username#localhost Rocket.chat]$ node main.js
/opt/Rocket.chat/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: not master and slaveOk=false
at Connection.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:450:61)
at Connection.emit (events.js:310:20)
at processMessage (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)
at Socket.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
ok: 0,
errmsg: 'not master and slaveOk=false',
code: 13435,
codeName: 'NotMasterNoSlaveOk',
[Symbol(mongoErrorContextSymbol)]: {}
}
The tutorial says I should be able to see the Rocket.chat web interface if I go to https://yourdomain.com:3000 but I get an unable to connect page, which I suppose is due to the error above
The tutorial also says node main.js is to check if MongoDB is running or not. I can see that MongoDb service is running by executing
systemctl status mongod
so this error seems to be caused by something else.
How do I find out what is causing this error? Or are there any mistakes in this tutorial? I have found other tutorials regarding installing Rocket.chat in CentOS but most of them use nginx as hte web server while I need to use Apache.

Not able to connect to mongodb when start node server

I am trying to run my node app locally on my VM.
When I am running command:
sudo NODE_ENV= XYZ PORT=80 node server/app.js
I'm getting error:
/node_modules/mongo-oplog/node_modules/mongodb/lib/mongodb/mongo_client.js:378
throw err
^ Error: connection closed
at null. (/node_modules/mongo-oplog/node_modules/mongodb/lib/mongodb/connection/server.js:605:24)
at emit (events.js:92:17)
at null. (/node_modules/mongo-oplog/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:155:15)
at emit (events.js:98:17)
at Socket. (//node_modules/mongo-oplog/node_modules/mongodb/lib/mongodb/connection/connection.js:528:12)
at Socket.emit (events.js:95:17)
My mongoDB is running fine and I can connect to local db with robomongo.
Any help would be highly appreciated on this.

Connection refused while connection elasticsearch in node

I am using node version 0.10.33 and elasticsearch version 3.0.0 but i am not able to connect to elasticsearch.
http://localhost:9200/
Elasticsearch ERROR: 2014-11-25T16:30:16Z
Error: Request error, retrying -- connect ECONNREFUSED
at Log.error (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/log.js:213:60)
at checkRespForFailure (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/transport.js:195:18)
at HttpConnector.<anonymous> (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/connectors/http.js:146:7)
at ClientRequest.bound (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1551:9)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
Trace: elasticsearch cluster is down!
at app.post.resturantController.ResturantInfo.name (/Users/shank/Documents/MyUmpa/Server/app.js:32:13)
at respond (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/transport.js:254:9)
at sendReqWithConnection (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/transport.js:174:7)
at next (/Users/shank/Documents/MyUmpa/Server/node_modules/elasticsearch/src/lib/connection_pool.js:213:7)
at process._tickCallback (node.js:419:13)
Have you run elastic search server? If not then Download Elasticsearch and unzip it into whatever directory you like. Next, open a terminal, cd to the directory you just unzipped, and run bin/elasticsearch (bin/elasticsearch.bat on Windows). After running elasticsearch server, run the node server!

error when starting the server with grunt or node server

I am trying to use the mean stack as described here : http://mean.io/
after install, when making "grunt", there is an error :
debugger listening on port 5858
4 Jan 01:47:40 - [nodemon] reading ignore list
Express app started on port 3000
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
4 Jan 01:47:40 - [nodemon] app crashed - waiting for file changes before starting...
I tried the troubleshooting as specified on the site : Updating Grunt, bower and cleaning npm and bower caches worked well. but updating npm gives an error too:
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
This looks like a conflict between homebrew and npm.
but anyway i have version 1.3.21 installed.
There is the same error when i am trying node server.
do you have an idea on what i can do to make the server work ?
It may be too easy, but seems like your MongoDB server is not actually running. After having installed Mongo (on your Mac, I assume?), you have to open a Terminal window/tab, run mongod and leave it running (or use screen, etc.). You can try to access MongoDB CLI by typing mongo to make sure the server is running.
#desgnl: if you don't want to run mongod command everytime you are running the grunt, you can always use third party services like MongoDB Hosting: Database-as-a-Service by MongoLab https://mongolab.com Hope this helps too!

Unhandled error event in node.js and express app

I was following along to this tutorial on "Authentication Using PassportJS" at this blog
And downloaded the files from his repo at https://github.com/DanialK/PassportJS-Authentication . And I intalled the packages that the terminal instructed me to. Then I attempted to run the app again but got this
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 3000
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at Server.connect.connectionPool.on.server._serverState (/Users/juangallardo/Desktop/PassportJS-Authentication-master/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:115:20)
at connection.on._self._poolState (/Users/juangallardo/Desktop/PassportJS-Authentication-master/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:91:17)
at Socket.errorHandler (/Users/juangallardo/Desktop/PassportJS-Authentication-master/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:88:17)
at Socket._destroy.self.errorEmitted (net.js:335:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
The problem was that I did not have MongoDB running
I found that "issue" discussed on GitHub
Then got the instructions to install and run mongo from this tutorial
brew install mongodb
Then you simply start the mongo server from the terminal with
mongod
Then back in your project just start the app with
node app.js

Resources