How to connect mongodb on Openshift

20 Nov 2014 web

Openshift provides us a lot of environment variables, we should use them whenever possible, so that we don't have to hard code anything in our code.

The following two env variables can helps us connect to mongodb easily

The complete connection string will be

OPENSHIFT_MONGODB_DB_URL + OPENSHIFT_APP_NAME

=> mongodb://admin:abcdefg@127.1.2.3:27017/foo

Pass the connection string to your mongodb client, and you should be able to use mongodb on Openshift!

comments powered by Disqus