How to setup my one-click mongoDB droplet to accept MONGO_URL connection from local meteor app (in development) with Windows7

August 25, 2016 261 views
MongoDB One-Click Install Apps Getting Started Ubuntu

I have create a one-click MongoDB Ubuntu 14.04 droplet and I want to be connected with this database from my local meteor application (which is in developing stage) bypassing the build-in mongo meteor db. I use Windows7 system in my local computer.

I need the mongo database to be in seperate droplet than meteor app for (future) flexibility and scalling. I need to build the database docs that meteor application will use from today (parallel with the meteor application development).

So far I have create the mongo droplet, enabled the ufw firewalls, and have make a batch commands file ("startMeteorInRemoteMongoURL.bat") with the commands:

"SET MONGO_URL = mongodb://**user:password**@**dropletIP**/**database**"

I use the batch file to run my meteor application local and I get as meteor error:

"Error: failed to connect to [**dropletIP**:27017]"

Do someone know to explane me analytic who do I have to setup the mongoDB droplet so to be able to connect from my local meteor app with MONGO_URL string connection?
I am nooby with Linux OS's.

Thank you.

1 Answer

By default, MongoDB will listen only on the localhost and not on your public IP. For this reason, applications running on a different server will not be able to connect to your MongoDB instance until you make some configuration changes.

For your meteor application you will likely need to allow a direct connection. This guide includes a section on this process. The key being to set your bind_address to something other than or localhost. Setting this to your droplet's public IP will allow a connection.

Once you have made this change, any computer on the internet could attempt to connect to your MongoDB service and this could pose potential security issues so it's strongly recommended that at the same time you set up a firewall like ufw or iptables to restrict access to your database server to just your local application's IP address.

by Etel Sverdlov
This article explains how to configure your MongoDB server securely and properly for a production-ready environment. It describes how to set up an SSH tunnel to your mongodb droplet.
Have another answer? Share your knowledge.