0

I have a docker-compose.yml file that runs a MongoDB instance. This is happening on a remote server.

The port for MongoDB is not exposed to the internet.

I am trying to be able to connect to this MongoDB instance.

version: "2.1"
services:

  ...

  database:
    image: mongo
    volumes:
    - data:/data/db
    ports:
    - "127.0.0.1:27017:27017"

volumes:
  data:
    name: data

The config in Studio 3T is... enter image description here enter image description here

When I used the "Test Connection" feature... enter image description here

Connection failed.

SERVER [example.com:22] (Type: UNKNOWN) |_/ Database error (MongoInternalException): The reply message length 759714643 is greater than the maximum message length 33554432

Details: Timed out after 5000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=example.com:22, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoInternalException: The reply message length 759714643 is greater than the maximum message length 33554432}}]

The connection string is...

mongodb://example.com:22/?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&3t.uriVersion=3&3t.connection.name=production&3t.ssh=true&3t.sshAddress=example.com&3t.sshPort=22&3t.sshAuthMode=password&3t.sshUser=root&3t.alwaysShowAuthDB=true&3t.alwaysShowDBFromUserRole=true

It worked when having the port exposed publicly to the internet, but I would like to avoid that.

pizzaisdavid
  • 455
  • 3
  • 13
  • Thanks for taking a look! On the "Server" tab, I changed port 22 to 27017 and example.com to localhost, and it made it work. You're a super-hero. If you make an answer, I will mark it as accepted – pizzaisdavid Mar 21 '23 at 16:31

1 Answers1

1

You connect to port 22 but the MongoDB runs on port 27017. Port 22 is only used for the SSH tunnel.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • A note if other people take a look at this. On the "Server" tab I also needed to change "example.com" to "localhost" – pizzaisdavid Mar 21 '23 at 16:35