# Pbm-agent fails on replica set SECONDARY: "get config server connection URI: mongo: no documents in result" (non-sharded RS)

**URL:** <https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377>\
**Category:** Percona Backup for MongoDB\
**Created:** [October 26, 2026, 10:40pm UTC](https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377 "2026-10-26T22:40:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshayrg09](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Akshayrg09](https://forums.percona.com/u/Akshayrg09)\
**Post date:** [October 26, 2026, 10:40pm UTC](https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377/1 "2026-10-26T22:40:23Z")

</div>

### PBM agent fails on non-sharded replica set secondaries during topology discovery

**Environment**

- MongoDB Community 8.0.34 (production) / 8.0.26 (sandbox)

- Non-sharded replica set `rs0` with primary and secondary members

- MongoDB running in Docker with host-port mapping

- Authentication enabled using keyFile

- PBM user: `pbmBackup` with `readWrite`, `backup`, `restore`, `clusterMonitor`, and `pbmAnyAction` privileges on `admin`

- PBM versions tested: 2.9.1, 2.14.0, and 2.17.0 — all exhibit the same failure

**Agent connection URI**

```auto
mongodb://pbmBackup:***@localhost:27027/?authSource=admin&directConnection=true

```

**Problem**

The PBM agent connects successfully when pointed at the primary but exits immediately when connected directly to a secondary.

```auto
E Exit: connect to PBM: get config server connection URI: mongo: no documents in result

```

**Investigation**

MongoDB command logging on the secondary confirms successful authentication followed by these commands:

1. `isMaster`

2. `getCmdLineOpts`

3. `find admin.system.version {_id: "shardIdentity"}` — returns zero documents, followed by agent exit.

The `isMaster` response contains normal replica-set fields (`setName`, `secondary`, `primary`, `hosts`, etc.), without `$configServerState` or `configsvr`.

The `getCmdLineOpts.parsed` response contains only `net`, `replication`, and `security`, with no sharding configuration.

**Expected behavior**

PBM should recognize the secondary as a member of a non-sharded replica set and initialize successfully.

**Actual behavior**

PBM attempts config-server URI discovery and exits when `shardIdentity` is absent.

**Impact**

PBM agents cannot initialize on secondary members, preventing the intended backup and point-in-time recovery configuration.

**Questions for Percona**

1. Why does PBM attempt config-server URI discovery on a secondary of a non-sharded replica set?

2. Could another configuration or connection property trigger this behavior?

3. Is this a known issue, and are there additional diagnostics or supported workarounds?

---

<div class="post-metadata">

**Author:** ![Deepak\_Rai](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/deepak_rai/32/24425_2.png) [@Deepak\_Rai](https://forums.percona.com/u/Deepak_Rai)\
**Post date:** [October 27, 2026, 4:58am UTC](https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377/2 "2026-10-27T04:58:57Z")

</div>

The issue is caused by `directConnection=true` in the PBM URI.

pbm-agent’s main connection needs to reach the primary. With `directConnection=true`, the agent on a secondary stays on that secondary only. Since it’s not the primary, PBM tries to find the config server and looks for the `shardIdentity` doc in `admin.system.version`. That doc doesn’t exist on a non-sharded replica set, so you get `no documents in result`. On the primary it works fine because it’s already the primary.

Please remove `directConnection=true` from the URI on all the agents, and point each agent to its own mongod, like:

`PBM_MONGODB_URI="mongodb://pbmBackup: **** @<node>:<port>/?authSource=admin"`

Since you are using Docker, make sure the `rs.conf()` hostnames are reachable from where pbm-agent runs, otherwise you’ll get `server selection error: context deadline exceeded`. The easiest fix is to run pbm-agent on the same Docker network as the mongod containers.

Let us know how it goes.

---

<div class="post-metadata">

**Author:** ![Akshayrg09](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Akshayrg09](https://forums.percona.com/u/Akshayrg09)\
**Post date:** [October 27, 2026, 4:50pm UTC](https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377/3 "2026-10-27T16:50:11Z")

</div>

Thanks Deepak, removing directConnection=true fixed it. All agents are now OK on every member, and backups and PITR are working. Appreciate the help!

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [October 28, 2026, 10:56am UTC](https://forums.percona.com/t/pbm-agent-fails-on-replica-set-secondary-get-config-server-connection-uri-mongo-no-documents-in-result-non-sharded-rs/41377/4 "2026-10-28T10:56:28Z")

</div>

Closed on October 28, 2026, 10:56am UTC


