Hi, I have mongodb installed locally on my osx laptop and on a remote ubuntu server. Both have mongodb running and I can verify this using the http diagnostics on port 28017. I'm running the same code on both computers. On osx everything works fine, but on Ubuntu I can't make a connection to the database through NodeJS. I keep getting this error:
Error: failed to connect to [localhost:27017]] message: listen EADDRNOTAVAIL stack: Error: listen EADDRNOTAVAIL at errnoException (net.js:769:11) at Server._listen2 (net.js:892:19) at listen (net.js:936:10) at Server.listen (net.js:993:9) at asyncCallback (dns.js:67:16) at Object.onanswer [as oncomplete] (dns.js:120:9) What I don't understand is that I can connect on Ubuntu locally via the mongo commandline interface. I can also connect to the database on Ubuntu via the mongo command on my OSX computer. So nothing seems to be wrong with the installation of MongoDB itself. Can anyone think of a reason why I can't connect via NodeJS? I have tried using the mongodb and mongoose packages. Both give me the same error. Here are the 2 ways I tried: var mongo = require("mongodb"); var host = "localhost"; var port = mongo.Connection.DEFAULT_PORT; var db = new mongo.Db('node-mongo-examples', new mongo.Server(host, port, {}), {}); db.open(function(err, db){ if(err){ log.error('MongoDB connection error:', err); }else{ log.info("OPEN MONGO CONNECTION"); } }); And the with mongoose: var mongoose = require('mongoose'); var db = mongoose.createConnection('localhost', 'node-mongo-examples'); db.on('error', function(err){ log.error('MongoDB connection error:', err); }); db.once('open', function () { log.debug("OPEN MONGO CONNECTION"); }); In the logs I see nothing special, and nothing happens either ***** SERVER RESTARTED ***** Wed Sep 26 18:00:18 [initandlisten] MongoDB starting : pid=13377 port=27017 dbpath=/var/lib/mongodb 64-bit host=octo-dev Wed Sep 26 18:00:18 [initandlisten] db version v2.2.0, pdfile version 4.5 Wed Sep 26 18:00:18 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207 Wed Sep 26 18:00:18 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49 Wed Sep 26 18:00:18 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" } Wed Sep 26 18:00:18 [initandlisten] journal dir=/var/lib/mongodb/journal Wed Sep 26 18:00:18 [initandlisten] recover : no journal files present, no recovery needed Wed Sep 26 18:00:18 [websvr] admin web console waiting for connections on port 28017 Wed Sep 26 18:00:18 [initandlisten] waiting for connections on port 27017 ..... except when I connect through the mongo commandline interface: Wed Sep 26 18:30:40 [initandlisten] connection accepted from 127.0.0.1:38229#3 (1 connection now open) I ran out of things to try. Anyone? Cheers, Thijs -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en