I'm trying to deploy my Node.js application on Render.com, but I'm encountering an error when connecting to MongoDB. Here are the details:
I'm using MongoDB with Mongoose in my Node.js application.
Locally, the application connects to MongoDB without any issues.
However, when deploying to Render.com, I'm getting the following error: "Failed to connect to MongoDB: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017".
I have verified that the MongoDB service is running and accessible.
I've tried using both the mongodb://127.0.0.1/iNotebook
and mongodb://localhost:27017/iNotebook
URIs, but the error persists.
I have also checked the firewall settings on Render.com and made sure that the MongoDB port (27017) is open.
I'm not sure why the connection is failing on Render.com but works fine locally. Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated.
Here is the link to both my Frontend and Backend repository:
https://github.com/aarontauro/iNotebook-Frontend
https://github.com/aarontauro/iNotebook-Backend
Thank you in advance for your help!
I faced the same issue. You can try this: