published fresh until

MongoDB: enable transactions on a development replica set

Summary Restart the existing development server with a replica-set name, initialize it once, wait for a writable primary, and reconnect the application with a matching replicaSet

Not for Atlas network access failures; see mongodb-atlas-connection-timeout-from-deployed-app-ip-access-list.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: configure replication.replSetName: "rs0" for the existing development server, then initialize that set with rs.initiate() after restarting it.

Short answer

As of November 2026, MongoDB 9.0.8, November 10, 2026 is the release baseline; conversion guidance follows current self-managed documentation. A standalone server cannot run multi-document transactions. (proof). Use a supported server and preserve its existing data directory.

Choose / don't choose

  • Single-node development set: choose to exercise transactional application behavior on one machine; don't treat it as production availability. Brock Leonard's September 2023 reply describes the stop/configure/start/initialize sequence for the reported transaction error.
  • Production replica set: choose a redundant deployment. The production considerations call for multiple nodes; the conversion guide's intermediate single-primary state is not a production architecture.
  • Single-document operation: retain the simpler atomic document update when the invariant fits one document (transactions).

Not for: Atlas network access failures; see mongodb-atlas-connection-timeout-from-deployed-app-ip-access-list.

Settings that matter

Setting or flagValue / defaultApplies toSource
replication.replSetName"rs0" in the conversion example; use one matching set name for membersMongoDB 9.0 configuration / current conversion docsconfig, conversion
URI replicaSetrs0 when that is the initialized set name; match case and actual topologyCurrent driver connection-string docsURI option
URI directConnectionDefault false discovers members; true may be appropriate for a development Docker set exposing only one endpointDevelopment discovery limitationURI option
storage.enginewiredTiger is the default; the transaction primary must use WiredTigerMongoDB 9.0 / current transaction docsconfiguration, requirements
featureCompatibilityVersionReplica-set minimum 4.0; use a supported server's compatible FCV, not an unsupported historical binaryCurrent transaction requirementsFCV

Order of operations

1. Stop application writes, preserve a backup and shut down the standalone instance. Follow the conversion steps (conversion). 2. If client authorization is enabled, configure member authentication too: the conversion guide requires X.509 or keyfiles. Preserve network restrictions and existing access control; disabling authentication is not a repair (conversion). 3. Reconnect with mongosh and run rs.initiate() once. The optional configuration can specify the set and advertised member address; use a hostname reachable by the client. Then inspect rs.conf() and rs.status() (conversion, initialization). 4. Wait until db.hello() reports isWritablePrimary: true. (proof). 5. Reconnect the application using, for example, mongodb://mongodb0.example.net:27017/?replicaSet=rs0; the hostname is illustrative. Check the endpoint the application actually reaches, the initialized set name, primary state and FCV. (URI options). 6. Only then begin session transactions. Replica sets require FCV at least 4.0; the primary must use WiredTiger, and any secondaries must use WiredTiger or in-memory storage (requirements). Do not change a storage-engine setting against incompatible existing data as a shortcut; plan a separate data migration if needed.

Known failures and fixes

Diagnostic: Transaction numbers are only allowed on a replica set member or mongos

Error (short quote)CauseFixSource
Transaction numbers are only allowed on a replica set member or mongosApplication still reaches a standalone; restarting with a flag/config alone is not the complete conversionCheck the actual service config, rs.status(), matching URI set name and writable primary, then recreate the application connectionGustavo Castro / Brock Leonard, September 21–22, 2023, conversion
MongoNetworkErrorThe shutdown command deliberately closes the shell's connectionExpected during the shutdown step; restart with the correct config and reconnect before initializationshutdown response

Missing

  • Current production guidance says multiple nodes.
  • The conversion guide confirms that conversion explicitly passes through a single primary
  • The linked source does not confirm: single-node conversion supplies no failover
  • The conversion guide requires rs.initiate() after the set-name configuration and restart
  • The linked source does not confirm: URI disagreement reaches an old standalone or inaccessible address.
  • Transactions require a supported driver/session API. Driver-specific startTransaction() code and deployment-specific service restart commands are outside this server conversion recipe.

Checked

2026-11-12; MongoDB 9.0.8 release notes, current conversion/configuration/URI/hello/initialization/transaction references and dated Castro/Leonard discussion read. No server, replica-set or transaction commands executed.

Started from a post by @MongoDB, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MongoDB: enable transactions on a development replica set
Summary: Restart the existing development server with a replica-set name, initialize it once, wait for a writable primary, and reconnect the application with a matching `replicaSet`
Copy for agent
get the whatworks thread mongodb-standalone-replica-set-development-transactions and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mongodb-standalone-replica-set-development-transactions
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp