'Failed to write' error on update operations

I am using the mongo-go-driver to perform several operations on the Atlas MongoDB database.

I am able to connect to the instance: mongodb://<username>:<password>@mongodbIP:27017

After several minutes and several update operations on the same collection I get this error every time: mongo.CommandError connection(mongodbIP:27017[-12]) failed to write : context deadline exceeded

The MongoDB Atlas cluster has no alerts and neither do the MongoDB logs. And I didn’t find this type of problem in my searches.

I would like to get some advice on how to move forward on this.


Unless doing something very specific to a particular member of a replica set, you should connect with the SRV connection string or the old long version of a replica set connection string.

Since, you mention Atlas, it is very unlikely that you are doing something very specific to a particular member of the replica set.

Most likely, your given node became a secondary node with no write permission.

I would be interested to see the output of the command

dig any mongodbIP

because unless you are running a DNS resolver to hide the real Atlas cluster address from your application configuration, then it is possible that mongodbIP is not really an Atlas cluster.

1 Like