My MERN app is trying to connect with the Atlas service to read and write some data.
Multiple times while firing up the backend server, I get this error: Error: connect ECONNREFUSED 43.205.72.30:27017
When I successfully connect, I work fine for a while, but it again throws an error.. There is a complete response I get:
{
"message": "connect ECONNREFUSED 43.205.72.30:27017",
"stack": "MongoNetworkError: connect ECONNREFUSED 43.205.72.30:27017\n at connectionFailureError (D:\\Projects\\MERN\\munch-lane\\node_modules\\mongodb\\lib\\cmap\\connect.js:379:20)\n at TLSSocket.<anonymous> (D:\\Projects\\MERN\\munch-lane\\node_modules\\mongodb\\lib\\cmap\\connect.js:285:22)\n at Object.onceWrapper (node:events:629:26)\n at TLSSocket.emit (node:events:514:28)\n at emitErrorNT (node:internal/streams/destroy:151:8)\n at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"
}
Initially, I was working on my WiFi, but other articles on the internet stated the same issues with WiFi, maybe due to port 27017 not being open on the router. So, I tried using my mobile hotspot, and it started working fine for a while before again throwing the same issues.
I have added 0.0.0.0 to the whitelist IPs. NodeJs version is v20.10.0
The connection string is: mongodb+srv://techmirtz:<password>@cluster0.yqhzzuj.mongodb.net/dbname?retryWrites=true&w=majority&appName=Cluster0
I see many similar questions addressed but most of them are for localhost one, not Atlas.