Skip to content

Using MongoDB Atlas in Cloud Foundry

This document describes how to bind a MongoDB instance from an own MongoDB Atlas account to an app running in Cloud Foundry.


All MongoDB instances in Cloud Foundry have been deleted on 31st October 2020 as communicated.

Create MongoDB cluster MongoDB Atlas

  1. Open MongoDB Atlas.
  2. Sign In or Create Account.
  3. Create MongoDB Cluster (in example MyCluster).


For eu1 region, create it on AWS in region Frankfurt For eu2 region, create it on Azure in region westeurope

4.Create Database Access User (in example myUser and myPwd). create-mongodb-user

Use MongoDB Atlas cluster in Cloud Foundry

  1. In MongoDB Atlas, navigate to your project and select Clusters.
    Click on CONNECT button of your cluster that you want to connect to. Select Connect your application.
  2. Select your driver and version.
  3. Copy the connection string
  4. Replace <password> with your password, you have created above (in example myPwd).
  5. With this change, you will have a connection string like this:

        mongodb+srv:// test?retryWrites=true&w=majority

  6. In cf cli, create an User-Provided-Service:

        cf cups <> -p "uri"


If you are using any connector for connecting to MongoDB instance, it may be required to set an tag or label to let the connector find the MongoDB URI in environment variables.
For example, Spring Cloud Cloud Foundry Connector requires a tag mongodb. For setting the tag, you can extend your cups command by -t "mongodb"

7.When requested for uri, insert your connection string

8.Bind User-Provided-Service to your app:

    cf bs <myapp> <>

9.Restage your app:

    cf restage <myapp>


  • Remember to change the service instance name to the User-Provided-Service in your manifest.yml
  • MongoDB TLS/SSL is standard
  • Latency time may be higher than before
    Tip: Create DB in AWS Frankfurt to minimize the latency time
  • Your application may need more outbound traffic
  • Note that your database endpoint is now accesible over internet. Please consider the security recommendations below and implement all additional security measures recommended by your organization.

Security Recommendations

  • Whitelist MongoDB Atlas cluster access for Cloud Foundry IP addresses only.
    You can find the Cloud Foundry IP addresses here.

Last update: August 9, 2023

Except where otherwise noted, content on this site is licensed under the Development License Agreement.