MongoError: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string

As suggested in accepted answer, you need to have your local server to be run as a replica set to be able to perform transactions, as opposed to standalone server.

However, in addition to the proposed solution, you can easily convert your Standalone local db to a Replica Set without using any third-party tool, by following instructions in MongoDB documentation, summarized as follows:

  1. Stop your standalone mongod instance, and restart it with the replSet argument.
mongod --port 27017 --dbpath /srv/mongodb/db0 --replSet rs0 --bind_ip localhost
  1. Connect to your instance with a mongo shell, and initiate the new Replica Set.
rs.initiate()

Now you should have a Replica Set instead of a Standalone mongodb server, where you can perform transactions on your local environment to update multiple documents at once!

Do not forget to include the replSet argument every time you want to start the server, otherwise it will be started as Standalone. I simply use the same command as in step 1 to run it again.


Alternatively, you can deploy a new Replica Set from scratch for testing environment following these other instructions in MongoDB documentation.


Transactions are undoubtedly the most exciting new feature in MongoDB 4.0. But unfortunately, most tools for installing and running MongoDB start a standalone server as opposed to a replica set. If you try to start a session on a standalone server, you'll get this error.

This issue can be resolved by using replica-sets on your local environment.

I have used run-rs for this purpose.


Please try adding &retryWrites=false to your connection string

--

I actually got the errors mentioned in the OP when connecting to our remote db server, whereas it was working locally. I contacted our mongo hosted support before trying the suggestion that is in the error.

--

This is what our hosted mongo site (mLab) said :

It's likely your app's driver was updated to a more recent version which is attempting to use a WiredTiger-only feature. As the error mentions, you'll need to add &retryWrites=false to your connection string.

https://docs.mlab.com/faq/#why-am-i-getting-the-transaction-numbers-are-only-allowed-on-storage-engines-that-support-document-level-locking-error