Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 608
François Romain Avatar asked Jan 04 '14 01:01

François Romain


2 Answers

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.

like image 109
bredikhin Avatar answered Sep 19 '22 07:09

bredikhin


@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!

like image 41
silent_programmer Avatar answered Sep 19 '22 07:09

silent_programmer