Hey guys,
So I have a free cluster on MongoDB Atlas for my node.js app. When I was developing the app, the connection to the database worked perfectly fine. Now I have deployed this app on a server and I get an error to connect to the remote db: MongoServerSelectionError: connect ECONNREFUSED
and
Hey @Ewan_Humbert - Firstly, welcome to the community
So I have a free cluster on MongoDB Atlas for my node.js app. When I was developing the app, the connection to the database worked perfectly fine. Now I have deployed this app on a server and I get an error to connect to the remote db
Regarding the above, could you advise on the following:
If the exact same code is being used (at least for the connection portion)
When the connection initially worked, was the app hosted locally on your device? E.g. on your laptop and connection was working fine to Atlas
When you get the errors connecting from the server where the app is deployed, have you tested connection from the initial development machine to compare if it was working during the same period?
Further details regarding the environment where the app fails to connect. E.g. Is this now hosted on AWS?
Driver version
I would also recommend you to please try performing the initial basic network connectivity tests and provide the output for the cluster you are having trouble connecting to (from the server where you have deployed your app):
Hey @Jason_Tran
Thank you so much for your answer!
I finally fixed the problem by authorizing the server to connect with the cluster, that’s pretty much it lol.
For those who face the same issue, and have access to the cPanel, just go to “SSH authorization”, and permit the cluster’s IP addresses that you find in your error message. And that’s pretty much it.