MongoDB Storage Plugin

The MonggoDB storage plugin is built-in to Porter. The plugin allows Porter to store its data in a MongoDB server. This plugin is suitable for production use.

Plugin Configuration

To use the mongodb plugin, add the following config to porter’s config file. Replace conn_str with the connection string for your MongoDB server.

default-storage: "mymongo"

  name: "mymongo"
  plugin: "mongodb"
    url: "conn_str"
    timeout: 10 # time in seconds

Config Parameters


The url configuration parameter specifies how to connect to a MongoDB server. The general format is below. See the MongoDB Connection String documentation for more details.


Only the host portion is required. The port defaults to “27017”, and the database to “porter”. Porter will create the database, collections and indices if they do not already exist.

Here is an example connection string for an instance of MongoDB running on localhost at the default port 27017, using the database name “mydb”.



Sets the timeout (in seconds) used for database queries. The default timeout is 10 seconds.

Cosmos DB

You can use Azure Cosmos DB API for MongoDB as a database with the mongodb plugin. The connection string to the database must be modified to work with Porter, the only supported query string option is ssl=true. See the Azure documentation for retrieving the ComosDB connection string. For example, if your connection string looks like this:


You need to remove the additional options and leave only the ssl=true option like so:


If you forget to remove the additional options from the connection string, you may see an error like the one below when connecting:

server selection error: context deadline exceeded, current topology: { Type: Unknown, Servers: [{ Addr:, Type: Unknown }, ] }

⚠️ There is a known performance issue when using CosmosDB with Porter that needs to be addressed: