11

I just updated to node 0.5.10 from 0.4.11 and my version of mongoose from 2.0.2 to 2.3.13 however I can no longer connect to localhost. My code has not changed at all, and I can still connect to my production server on mongolab. I can connect to my local db using a gui (MongoHub) just going through localhost. I am now running out of ideas. I've tried variations on the following connection strings which both should work in my option.

mongodb://localhost:27017/mydb
mongodb://localhost/mydb

I have even created a very basic single app to just save something to my localhost but to no avail. Ideas are very welcome!

var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/SomeDb');

var Schema = mongoose.Schema;
var Posts = new Schema({
  name : String,
});
mongoose.model('Post', Posts);

function createNewPost(){
    var Post = mongoose.model('Post');
    var post = new Post({name:'new name'});
    post.save(function(err){
      console.log("saving");
        if(!err){
            console.log('Post saved.');
        }
    });
}
5
  • Obvious, but did you reinstall all of the modules/drivers?
    – Mike
    Nov 19, 2011 at 0:36
  • thanks, yep including new mongodb. Nov 19, 2011 at 9:21
  • 1
    Why are you on 0.5.10? 0.6 (stable) is already out. Nov 19, 2011 at 16:12
  • Part of the reason was I was expecting everything to break upgrading node so I wanted to do it in 2 steps 0.4.11 -> 0.5.10 then 0.5.10 -> 0.6.x. I am now running 0.6.2 successfully. Nov 20, 2011 at 13:21
  • what does ip address does 'localhost' resolve to on your system?
    – EhevuTov
    Nov 24, 2011 at 0:31

1 Answer 1

17

After debugging using the mongodb native I found that 127.0.0.1 works. I have not idea but I am back up and running.

mongodb://127.0.0.1/mydb
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.