Cannot Connect to MongoDB Replica Set via MongoDB Compass – "Not Found" Error

I am facing an issue while trying to connect to a MongoDB replica set (mongodb-1 and mongodb-2 containers) using MongoDB Compass. The replica set is set up and running in Docker, but when I attempt to connect using Compass, I receive a “Not Found” error.

Configuration:

MongoDB Version: mongo:latest (Docker container setup)

Replica Set Name: rs0

MongoDB Containers:

mongodb-1: Running on port 27018

mongodb-2: Running on port 27019

Docker Compose Configuration:

mongodb-1:
  image: mongo:latest
  container_name: mongodb-1
  command:
    [
      "mongod",
      "--port",
      "27018",
      "--replSet",
      "rs0",
      "--bind_ip_all",
      "--keyFile",
      "/data/configdb/keyfile",
    ]
  ports:
    - "27018:27018"
  restart: unless-stopped
  environment:
    - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
    - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
    - MONGO_REPLICA_SET_KEY=${MONGO_REPLICA_SET_KEY}
    - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE}
  volumes:
    - "./init-keyfile.sh:/docker-entrypoint-initdb.d/init-keyfile.sh"
    - mongodb-1:/data/db
    - mongodb-1-configdb:/data/configdb

mongodb-2:
  image: mongo:latest
  container_name: mongodb-2
  command:
    [
      "mongod",
      "--port",
      "27019",
      "--replSet",
      "rs0",
      "--bind_ip_all",
      "--keyFile",
      "/data/configdb/keyfile",
    ]
  ports:
    - "27019:27019"
  restart: always
  environment:
    - MONGO_REPLICA_SET_KEY=${MONGO_REPLICA_SET_KEY}
  volumes:
    - "./init-keyfile.sh:/docker-entrypoint-initdb.d/init-keyfile.sh"
    - mongodb-2:/data/db
    - mongodb-2-configdb:/data/configdb

Problem:

When I try to connect using MongoDB Compass, I receive a “Not Found” error. I have confirmed that the MongoDB replica set is initialized, and both mongodb-1 and mongodb-2 containers are running.

Connection String I am using:

mongodb://<username>:<strongpassword>@135.13.00.00:27018,135.13.00.00:27019/?authSource=admin&replicaSet=rs0

I am able to ping the MongoDB containers, and ports 27018 and 27019 are open, but MongoDB Compass still returns the error.

What I Have Tried:

Verified that the replica set is initialized using rs.initiate() in the MongoDB shell.

Double-checked the connection string format and MongoDB credentials.

Ensured that the containers are reachable from my local machine.

Made sure that the bind IP configuration (–bind_ip_all) allows external connections.

Additional Information:

The MongoDB containers are running on Docker and I am accessing them from my host machine IP (135.13.00.00).

MongoDB Compass is configured with replicaSet=rs0, authentication enabled, and proper credentials.

Request:

Can anyone help me understand why I am receiving this “Not Found” error, and what steps I might have missed to correctly connect to the MongoDB replica set from MongoDB Compass?
Thank you!