MongoDB replicaSet error AuthenticationFailed (code 18)

You have not given the result of having 0.0.0.0 in your config files. This is an important step to identify possible problems.

and a TL:DR for my above post would be if you need to connect from multiple networks, mongodb server should be set to listen to:

  • localhost/127.0.0.1 so you can log in inside the container (not needed if port forwarded to host)
  • any other IP address this container is set to have, including host VPS’s external IP. you may set a whole address set with what I described in later sentences.

otherwise, the server will just reject all incoming connections that are not included in the whitelist.

you seem to have done most of the job but seeing your config file would really help to find a solution faster.