How to connect Render App to Render MongoDB database

Hello everyone!
I’ve hosted my first app on render, a chat app, however it needs a mongoDB database to run correctly.
Usually while developing the app I would use the mongoDB database that I have downloaded locally on my machine, and link it in my nodeJs file using something like “'mongodb://localhost:27017/chatApp”. However, I am not sure how to link the Render app to the render mongoDB that I deployed by following this link: Deploy MongoDB | Render · Cloud Hosting for Developers

Thank you in advance for your support!

Hi @Guy_M,

Welcome to the Render community! Your MongoDB service should be accessible to your NodeJs app using the host:port displayed in your dashboard so something like mongodb://mongo-xyz:27017

Hey Tyler!
Thank you for the quick reply! I was able to solve this issue by using mongoDB Atlas, the mongoDB cloud database service.

Hi, I just created mongodb using “deploy to render” button here Deploy MongoDB | Render · Cloud Hosting for Developers

Should I be able to connect to mongodb with given host:port from my other private service without additional configuration?

I haven’t been able to connect yet

edit: I have added the mongodb://host:port to environment variables

Solved the problem! Apparently mongo private service needed to be on same location (Frankfurt) to work as the other service

Solved the problem! Apparently mongo private service needed to be on same location (Frankfurt) to work as the other service

[Discourse post]

1 Like