Skip to content
MongoDB

MongoDB Error 89

NetworkTimeout: a network operation between MongoDB processes timed out

Applies to: MongoDB 7.0 and 8.0 (wordings checked against the 8.0 source)
Last technically reviewed 24 October 2026 on MongoDB 8.0 documentation and source (error_codes.yml r8.0.0); not run locally
The full message
Socket operation timed out
Other forms of this message
A connection attempt that did not complete in time
Error connecting to m2.example.net:27017 (10.0.0.12:27017) :: caused by :: Connecting timed out
A synchronous connection attempt that did not complete in time
Error connecting to m2.example.net:27017 (10.0.0.12:27017) :: caused by :: Timed out
A TLS handshake that did not complete in time
SSL handshake timed out after 10000ms
Python: PyMongo's own NetworkTimeout class is a different, client-side error
pymongo.errors.NetworkTimeout: ...
Error code
89
Code name
NetworkTimeout
Product
MongoDB
Versions
MongoDB 7.0 and 8.0 (wordings checked against the 8.0 source)
Last reviewed
24 October 2026

What it means

Error 89 (NetworkTimeout) means MongoDB's network layer gave up on a socket operation or a connection attempt to another MongoDB process because it ran past its time limit. It is mostly seen between servers and in server logs, not in application code.

MongoDB's transport layer raises NetworkTimeout when a read or write on a socket times out (Socket operation timed out), when a connection or TLS handshake to another host does not finish in time, and in a few internal checks. error_codes.yml places it in three categories: NetworkError, RetriableError and NetworkTimeoutError, which MongoDB's own components use to decide whether to retry and how to treat the remote host.

Two details explain why you may rarely see the number 89 itself. First, several callers translate it: in MongoDB 8.0 the server's connection pool reports a failed connection attempt as 6 HostUnreachable, and the C++ client does the same, keeping the original text, so Connecting timed out can appear with code 6. Second, request time limits use other codes: an operation that exceeds maxTimeMS is 50 MaxTimeMSExpired, and a request that waits too long inside the server's network interface is reported as 202 NetworkInterfaceExceededTimeLimit.

Drivers have their own time-outs and errors. PyMongo, for example, has a class called NetworkTimeout, which its source documents as "An operation on an open connection exceeded socketTimeoutMS"; that is a client-side exception in your application, not this server code. A driver that cannot reach any server at all reports a server selection timeout.

Common causes

  • High latency or packet loss between replica set members, or between mongos and shards, for example across regions.
  • A firewall or proxy that silently drops packets instead of refusing them, so connections hang until they time out.
  • An overloaded or stalled remote host (CPU, memory or disk saturation) that does not answer in time.
  • TLS handshakes that are slow because of certificate checks or DNS lookups on the remote side.
  • Very short internal or tool time-outs for the network in use.

Diagnose it

Read-only These mongosh commands only read data, indexes, statistics and server state (find, aggregate without $out or $merge, getIndexes, stats, currentOp, rs.status). They do not change data, users or settings, so they are safe to run first.

Round-trip times and heartbeat messages between members

rs.status().members.map(m => ({ name: m.name, state: m.stateStr, pingMs: m.pingMs, msg: m.lastHeartbeatMessage }))
What to look for

pingMs is the round-trip time from this member to each other member. High or very uneven values, or heartbeat messages mentioning time-outs, point to the network path.

Recent log entries with code 89

db.adminCommand({ getLog: "global" }).log.filter(l => l.includes('"code":89'))
What to look for

Recent structured log lines that carry the code. Each one names the component and the remote host, which tells you which connection is timing out.

Network counters on the server

db.serverStatus().network
What to look for

Network counters such as bytes and requests in and out. Compare snapshots taken a minute apart during the problem to see whether traffic is still flowing.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Fix the network path between the processes

Changes configuration

Measure latency and packet loss between the hosts named in the errors (the troubleshooting guide suggests ping and traceroute), and fix the route, firewall or proxy. A firewall should refuse or allow the port, not drop packets.

Relieve the slow host

Changes configuration

If one host is saturated (CPU, memory, disk), reduce its load or give it more resources; slow answers from an overloaded member show up as time-outs on the others.

Treat the error as transient in your own code

Client or network side

When an error relayed to your application carries code 89, retry the operation with a back-off, as for other errors in the RetriableError category; make writes idempotent so a retry is safe.

Examples

A connection time-out reported with code 6

Not reproduced here: no MongoDB server is installed for this site. The text is built from NetworkTimeout in MongoDB 8.0's asio_transport_layer.cpp; connection_pool_tl.cpp then reports it as HostUnreachable (6) with the same text, which is why this page explains both. The host names are illustrative.

rs.status().members[2].lastHeartbeatMessage
Expected result (documented format, not run)
Error connecting to m3.example.net:27017 (10.0.0.13:27017) :: caused by :: Connecting timed out

Finding NetworkTimeout entries in the log

Not reproduced here: no MongoDB server is installed for this site. The error object uses the fields Status::serialize() writes in MongoDB 8.0 (code, codeName, errmsg) and the message text from asio_utils.cpp; the rest of the log line is shortened and illustrative, and getLog returns only recent entries.

db.adminCommand({ getLog: "global" }).log.filter(l => l.includes('"code":89')).slice(-1)
Expected result (documented format, not run)
[ '{"t":{"$date":"..."},"s":"I","c":"...","msg":"...","attr":{"error":{"code":89,"codeName":"NetworkTimeout","errmsg":"Socket operation timed out"}, ...}}' ]

How to prevent it

Keep members of a replica set on low-latency links, monitor pingMs and replication lag, and alert on repeated network errors in the logs before they turn into elections.

Configure firewalls to allow or refuse MongoDB ports explicitly, and size hosts so that no member becomes too slow to answer heartbeats.

Common questions

What does NetworkTimeout (89) mean in MongoDB?

A socket operation or a connection attempt between MongoDB processes ran past its time limit. Look at the network path and the remote host named in the log entry.

Is this the same as PyMongo NetworkTimeout?

No. PyMongo's NetworkTimeout is a client exception raised when an operation on an open connection exceeds socketTimeoutMS. Server code 89 is raised inside MongoDB.

Why does the same "timed out" text appear with code 6?

In MongoDB 8.0 the server's connection pool reports failed connection attempts, including time-outs, as HostUnreachable (6) and keeps the original text.

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on MongoDB 8.0 documentation and source (error_codes.yml r8.0.0); not run locally. Codes and code names are checked against MongoDB's error_codes.yml (8.0); no MongoDB server was available, so the examples were not run locally.

Still stuck on a MongoDB error?

Browse the full MongoDB error library, or get hands-on help from an experienced SQL professional.