Metricbeat mongodb no reachable servers error

Hello.

I have a MongoDB replica set with version 4.2.0 running in Kubernetes and I tried to add metricbeat monitoring to a secondary node (metricbeat version 7.6.1). Metricbeat successfully authenticates with a user that has clusterMonitor privileges, but then it writes the following exception in /var/log/metricbeat/metricbeat :

2020-03-24T08:31:11.918Z        INFO    module/wrapper.go:252   Error fetching data for metricset mongodb.replstatus: error getting replication info: no reachable servers

The mongo module file is below:

- module: mongodb
  hosts: ["localhost:27018"]
  period: 10s
  username: ''
  password: ''
  metricsets: ["dbstats", "status", "collstats", "metrics", "replstatus"]

I found https://github.com/elastic/beats/issues/4689 but it should have been fixed. Does anyone else have any ideas on how to fix this? Thank you.