I have 2 rackspace servers.
I'm trying to connect to my database with mongoose like (in my app.js on [Server 1]):
// DB
var mongoose = require('mongoose');
var MongoStore = require('connect-mongo')(express);
var dbSession = 'mongodb://root:password@[Server 2]:27017'
mongoose.createConnection(dbSession);
On [Server 2] in /etc/mongo.conf, the only things that are turned on are:
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongodb.log
logappend=true
# Bind ip for our app server
bind_ip=[Server 1]
How can I: A) Check to see if I'm able to connect to [Server 2] from [Server 1] and actually get it working?
Not sure about your firewall configuration, but you may need to open port 27017 on the mongodb server (Server 2 in your setup). Something like the following:
sudo iptables -A INPUT -p tcp --dport 27017 -s [APP_SERVER IP ADDRESS HERE] -j ACCEPT
If you haven't setup firewall rules yet, I suggest reading the Ubuntu guide for Iptables: https://help.ubuntu.com/community/IptablesHowTo
Also, if you aren't already, you'll probably want to use the private IP address communicate between the servers:
http://www.rackspace.com/knowledge_center/article/using-the-private-ip-address-on-your-cloud-server
UPDATE -- 09/22/2013
I spun up 2 Rackspace servers and performed the steps below to successfully communicate between them.
tl;dr The problem might be the bind_ip parameter in your /etc/mongo.conf file.
If you copy and paste these commands, remove the '[remove this]' piece in the links when installing mongodb.
Server 1:
Here is the server.js file I used:
var express = require('express')
var mongoose = require('mongoose');
var MongoStore = require('connect-mongo')(express);
var dbSession = 'mongodb://[Server 2]:27017';
mongoose.connect(dbSession);
var Dog = mongoose.model('Dog', {name: String});
var dog = new Dog({name: 'Fido'});
dog.save(function(err){
if(err){
console.log(err);
}
else{
console.log('success');
}
});
Server 2: