MongoDB

The Railway MongoDB database service allows you to provision and connect to a MongoDB database with zero configuration.

Deploy

Add a MongoDB database to your project via the CMD + K menu or by clicking the + New button on the Project Canvas.

GIF of the Adding Database

Connect

Connect to MongoDB from another service in your project by referencing the environment variables made available in the Mongo service:

  • MONGOHOST
  • MONGOPORT
  • MONGOUSER
  • MONGOPASSWORD
  • MONGO_URL

Connecting externally

It is possible to connect to MongoDB externally (from outside of the project in which it is deployed), by using the TCP Proxy which is enabled by default.

Keep in mind that you will be billed for Network Egress when using the TCP Proxy.

Image

The MongoDB database service uses the Docker official mongo image.

Custom Start Command

The MongoDB database service starts with the following Start Command to enable communication over Private Network: mongod --ipv6 --bind_ip ::,0.0.0.0

Changing System Variables

Tailor your MongoDB service to your needs by adding any variables relevant to the mongo image.


Edit this file on GitHub