0

I ran node server.js in topmost directory of my project:
And this is the error which I got:

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
The magic happens on port 8080

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [your_database_here:27017]
    at null.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:549:74)
    at emit (events.js:106:17)
    at null.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
    at emit (events.js:98:17)
    at Socket.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
    at Socket.emit (events.js:95:17)
    at net.js:833:16
    at process._tickCallback (node.js:419:13)

I've installed mongodb and when I open localhost:27017 in browser, it says It looks like you are trying to access MongoDB over HTTP on the native driver port.. Where is the exact mistake?

1 Answer 1

2

I suggest you to use 'mongoose' to connect with mongodb from node. Here is the sample code to do this.

var mongoose=require('mongoose'),
    db = 'mongodb://localhost/test';

mongoose.connect(db);

//and your code goes here

You have to install node module 'mongoose'. Read the docs of mongoose.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.