Docs Menu

Docs HomeLaunch & Manage MongoDBAtlas CLI

Save Connection Settings

On this page

  • Locate the Configuration File
  • Create a Profile
  • Update a Profile
  • Run a Command with a Profile

You can save your frequently-used connection settings as profiles. Profiles store the project IDs, organization IDs, and, optionally, API keys to use in future Atlas CLI sessions. To save time, you can specify a profile instead of using the --projectId and --orgId flags with each command. The Atlas CLI stores your profiles in a configuration file called config.toml.

Note

Any settings stored in environment variables take precedence over settings stored in profiles. Any project or organization specified with the --projectId and --orgId flags take precedence over both the profile and the environment variables.

The Atlas CLI saves the configuration file to the following location depending on your operating system:

The Atlas CLI grants the user who ran the command read and write access to the file.

The first time you run the atlas auth login or atlas config init command, the Atlas CLI automatically creates the config.toml file and a default profile. If you run a command without specifying a profile, environment variables, or --projectId and --orgId flags, the Atlas CLI uses the default profile for the command.

Select a connection method based on your use case:

Command
Authentication Method
Use Case
atlas auth login
Atlas login credentials and an authentication token
Best for non-programmatic use
atlas config init
API keys
Best for programmatic use

To learn more, see Select a Connection Method.

  • Install the Atlas CLI.

  • Add your host's IP address to the IP access list.

  • If you select atlas config init as your connection method, you must Configure API keys.

  • If your Atlas CLI installation is behind a firewall and you want to use a proxy URL, set up the HTTP_PROXY or HTTPS_PROXY environment variable.

    Important

    Atlas CLI supports http, https, and socks5 schemes. You must specify cloud.mongodb.com/ as the main target URL in the proxy service's access list. You must also specify the username and password if your proxy configuration enables authentication.

    To learn more, see Proxy server.

Select a use case and follow the procedure to create a profile.

You can update the settings stored in your configuration file in the following ways:

  • Edit the config.toml file with a text editor.

  • Run the atlas config set command for a setting. This edits an individual value in the config.toml file.

To run an Atlas CLI command using a profile:

  • Create a Profile.

  • Append the --profile <profileName> flag to a command or omit the --profile <profileName> flag to use the default profile.

Example

This command uses a profile named myProfile:

atlas <command> --profile myProfile

This command uses the default profile:

atlas <command>
←  Connect from the Atlas CLIMigrate to the Atlas CLI →