node.js - Cannot fetch from or insert data to mongodb using mongoose -


i wrote node web app , created mongodb database on local system. using following code connect local mongodb node js

var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/db_name'); //local 

and working fine on local machine. went on , created mlab account , created database. when tried run code changing connection string, connections still established believe. find , save requests not invoking callbacks, no errors shows up. requests getting timed out.

var mongoose = require('mongoose'); mongoose.connect("mongodb://user:pass@ds036789.mlab.com:36789/db_name"); //mlab 

another thing noticed cannot ping ds036789.mlab.com. tcp connections succeeding when tried nc command

nc -w 3 -v ds036789.mlab.com 36789 

i tried deploying azure. doesn't work either. appreciated. thanks.

edit: not being able ping due fact used azure hosting. expected. , found out error while trying connect :

connection error: { [mongoerror: auth failed] name: 'mongoerror', ok: 0, errmsg: 'auth failed', code: 18 } 

credentials correct though.

from error mesasge seems using invalid auth details

this happen when not create username , password individual database i.e, db_name in case.

check mlabs account , create username , password db_name database , update connection string.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -