3

I nave nodejs server and connecting to Mongo DB locally using mongoose as:

mongooseQ.connect("mongodb://localhost:27017/YepiMobile"); 

How can I connect to mongo db that locating on remote server from my machine?

Something like:

mongooseQ.connect("mongodb://remote.server.com:27017/YepiMobile"); 
1
  • Does the above fail when you put in the correct hostname for the remote server? It looks like it should work. What's the error you see if it fails? Commented Sep 11, 2014 at 18:58

1 Answer 1

5

Does the second connection attempt fail for you, by reading Mongoose's documentation it seems like you have done it correctly:

mongoose.connect('mongodb://username:password@host:port/database?options...'); 

Maybe you are missing the credentials to the server? See this link for more information: http://mongoosejs.com/docs/connections.html, or see MongoDB's connection documentation: http://docs.mongodb.org/manual/reference/connection-string/.

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

3 Comments

@Simha did this help any?
in here username and password means server username and pasword ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.