Skip to main content

Connect to database with Floating IP

Connecting to a MongoDB cluster takes two things: network access and credentials. You open access with a Security Group, and add a Floating IP if the client sits outside the VPC.

If your application already runs inside the same VPC, you can skip the Floating IP step entirely. That is the recommended shape for production.

info

Creating the Security Group, allocating and associating the Floating IP, and reading the connection details off the console are documented once in Connect to database with Floating IP. The steps are identical for MongoDB.

Prerequisites​

  • A cluster in Running status. See Create your first database.
  • Permission to manage Security Groups and Floating IPs in the VPC.
  • A MongoDB client, mongosh, or a driver for your language.

How connections reach the cluster​

Each cluster is provisioned with a standard MongoDB connection endpoint, expressed as a MongoDB URI. Connecting through that endpoint rather than a node address keeps your application decoupled from the cluster's internal topology, so a failover or a topology change costs you nothing, and leaves you one connection string to manage rather than several.

Two access models are available:

ModelWhat it allowsUse it for
Private AccessConnections only from internal networks such as the VPCProduction and anything with strict security requirements
Public AccessA public endpoint reachable from the internet, with additional controlsExternal integrations, temporary administrative access, development and testing
warning

Before enabling public access, weigh the security, performance, and architectural consequences. A public endpoint widens the attack surface permanently, not only while you are using it.

What differs for MongoDB​

  • The inbound rule on the Security Group must open the MongoDB port your cluster listens on.
  • A Floating IP attaches to an individual node, not to the cluster endpoint. In the allocation dialog you set Resources to Instance and pick the node.
  • Typical reasons to attach one: access from on-premises or external systems, temporary administrative work, and testing or integration.

Connect with a client​

Read the endpoint, port, database name, username, and password from the Overview tab of the cluster detail page.

Then connect in whichever way suits your workflow:

  • MongoDB Compass or another management tool, supplying the endpoint, port, credentials, and database name.
  • mongosh from a terminal, using the connection URI.
  • An application, using the official MongoDB driver for your language.

Once connected, you can browse collections and run queries.

note

If the connection times out, the cause is almost always network policy rather than credentials. Check the Security Group inbound rules first — a missing rule for the MongoDB port is the usual omission.

Next steps​