Setting up a MongoDB server on DigitalOcean

Since DigitalOcean’s cheapest droplet is $5, I was thinking I could use it as a budget hosting option. Problem is, I have had no luck figuring out how to setup the system properly. Whenever I try to do it I get:

MongoError: failed to connect to server [xxx.xxx.xxx.xxx:27017] on first connect.

I have tried different combinations of MONGO_URL. With and without username/password, with and without port, with and without database name, etc. Nothing seems to work, and no matter what I do the error message doesn’t change. Also noticed that pinging the IP always times out.

The DigitalOcean side configuration seems to be correct. It was started using DigitalOcean’s own one-click MongoDB installation.

netstat results

root@mongodb-512mb-nyc2-01:~# sudo netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1466/mongod
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1501/sshd
tcp6 0 0 :::22 :::* LISTEN 1501/sshd

db.serverCmdLineOpts() Results
> db.serverCmdLineOpts()
{
	"argv" : [
		"/usr/bin/mongod",
		"--quiet",
		"--config",
		"/etc/mongod.conf"
	],
	"parsed" : {
		"config" : "/etc/mongod.conf",
		"net" : {
			"bindIp" : "127.0.0.1",
			"port" : 27017
		},
		"storage" : {
			"dbPath" : "/var/lib/mongodb",
			"journal" : {
				"enabled" : true
			}
		},
		"systemLog" : {
			"destination" : "file",
			"logAppend" : true,
			"path" : "/var/log/mongodb/mongod.log",
			"quiet" : true
		}
	},
	"ok" : 1
}
database users

I tested with all of thesePreformatted text

{
	"_id" : "test.mynewuser",
	"user" : "mynewuser",
	"db" : "test",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "test"
		},
		{
			"role" : "dbAdmin",
			"db" : "test"
		}
	]
}
{
	"_id" : "test.myTester",
	"user" : "myTester",
	"db" : "test",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "test"
		}
	]
}
{
	"_id" : "test.myTesterTwo",
	"user" : "myTesterTwo",
	"db" : "test",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "local"
		}
	]
}

Although I doubt it’s a Metor end problem, my start script is:

export MONGO_URL=(tried a bunch of different combinations here, none worked)
meteor run --port $PORT

I have connected to a mLab database before using this script.

Can anybody give me some instructions and/or guidance on how to setup the DigitalOcean MongoDB server properly, and connect to it to Meteor properly?

Hi,

You could try the steps here -

esp the section about modifying the firewall to allow access to Mongo from outside. Roughly the same steps need to be done if you use the 1-click mongo app, as listed here -

My guess is the port isn’t opened.