We have some single sharded clusters running, and i see some errors in the log as below, everything is running on docker containers. I also have a running 3 node cluster, and it works perfectly with same setup. I cant seem to figure out why this error is happening.
When running Mongodb, is says “PRIMARY”
Error:
time="2025-08-18T07:25:26Z" level=error msg="failed to create PBM client from uri mongodb://mongodb_ix_data_master:27017: create mongo connection: ping: server selection error: context deadline exceeded, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] }" collector=pbm
I think it’s possible you are hitting a race condition. The mongod process needs to have finished initializing before both pbm and pmm agents can connect to it. Would it be possible for you to use separate containers?
Thanks for the reply, I cannot run in seperate containers, but the race condition is allready taken care of from my startup scripts in the container, so it checks if its finished init, before starting pbm. and the wierd part is, that PBM is acctully working perfetly, just getting the error in the mongodb exporter contaniner. So it seems like the exporter that cannot connect to mongodb, and not pbm
Understood. Can you show us the configuration you are using for pmm-agent? this is what runs mongodb exporter. It should point to localhost, not the replicaset URI
shouldn’t you be putting user and password as part of the connection URI? also the direct option probably makes sense to avoid replica set auto discovery. Something like: