Error connecting to database: MongoServerSelectionError: connection <monitor> to closed

I’m getting this error when I’m using render or railway. So far I’ve tested both the connection string and network connectivity which both work. mongodb+srv://

This error indicates the driver fails to find a server based on your preference (e.g. read preference).

What read preference you use? by default it should be primary, can you check if you have a primary running

i never use atlas. is your deployment a replica set or sharded cluster?

check this.

It’s a replica set with two secondary and one primary cluster.