Skip to main content

IO Config Setup Guide

The io_config file is a crucial configuration file in Mage that stores credentials and connection information for accessing various data sources. This guide will help you understand where to store it and how to create it from scratch.

File Location

The io_config file should be stored in your Mage project’s root directory. The default path is:
For detailed information about project structure and file organization, see the Project Structure documentation.

Creating a New io_config File

1. Basic Structure

Create a new file named io_config.yaml in your project’s root directory (e.g. /home/src/your_mage_project) with the following basic structure:

2. Configuration Formats

Mage supports two formats for the io_config file:

Legacy Format (Verbose)

3. Using Variables and Secrets

For security, it’s recommended to use environment variables and other secret management systems for sensitive information. Mage provides several variable syntax options:

Variable Syntax

Example Configurations

Environment Variables:
Mage Secrets:
AWS Secrets Manager:
Azure Key Vault:
Google Cloud Secret Manager (Mage Pro only):
Doppler:
To use Doppler, configure the Mage runtime with DOPPLER_TOKEN, DOPPLER_PROJECT, and DOPPLER_CONFIG. Mage caches Doppler secrets in memory for DOPPLER_SECRETS_CACHE_TTL_SECONDS seconds, defaulting to 10. Set the TTL to 0 to refresh on every lookup. Secret changes are picked up on the next config render after the TTL expires; already-open connections may continue using the previous value until recreated. File Content (Mage Pro only):
JSON Value Extraction:

4. Multiple Profiles

You can create multiple profiles for different environments or use cases:

Managing profiles in the UI

You can create, update, delete, and test io_config.yaml profiles from the Mage UI:
  1. Open Settings.
  2. In Workspace, select Data connections.
  3. Select an existing profile or choose Add profile. You can also open /settings/workspace/io-config directly.
Viewers can inspect profiles with masked credentials. Creating, renaming, saving, deleting, and testing requires Editor access plus notebook edit access; otherwise, the page is read-only.

Create and save profiles

  • Enter a profile name before choosing a provider or editing YAML. New profiles start with Full profile and an empty YAML mapping.
  • Select Save, press Command+S on macOS, or press Ctrl+S on Windows and Linux.
  • Profile names can contain up to 128 letters, numbers, periods, underscores, and hyphens. They must start with a letter or number, cannot contain spaces, and cannot be version.
  • Mage confirms before deleting a profile or discarding an unsaved name or configuration change.
  • If another user changes io_config.yaml, Mage rejects your stale save or delete. Reload before applying the edit again.

Edit provider configuration

Select a provider to edit only its keys, or select Full profile to edit the complete profile YAML.
  • The backend supplies the provider list, YAML templates, and connection-test capabilities.
  • Checked providers show their configured-value count. Blank template defaults are not saved or counted.
  • Saving one provider preserves unrelated provider keys in the same profile. Removing a key removes it only from the selected provider scope.
  • Clear provider keys resets that provider’s draft; select Save to persist the removal.
  • Provider-scoped editing rejects mixed or custom keys. Use Full profile for those keys.
  • Providers can share credential groups, such as AWS or DuckDB keys. Editing or clearing a shared group affects every provider that uses that group but preserves unrelated keys.
Switching providers with an unsaved draft prompts you to Keep editing or Discard changes.

Work with masked secrets

Sensitive values appear as ********.
  • Leave the mask unchanged at the same YAML path to preserve the saved value.
  • Replace it to update the secret, or remove the key to delete the value.
  • Mage rejects a mask when no saved secret exists at that path.
  • Lists containing masked secrets must remain unchanged. Replace the masks with explicit values before adding, removing, reordering, or editing list items.

YAML limitations and recovery

Profiles must be YAML mappings with string keys. A profile can be at most 1 MiB, and the full io_config.yaml file can be at most 10 MiB. The UI rejects YAML tags, sets, binary values, timestamps, anchors, aliases, merge keys, and other non-JSON-safe or cross-profile graph features without rewriting the file. Edit io_config.yaml directly to preserve or remove unsupported constructs.
  • For invalid YAML, fix the file and select Retry.
  • For a symbolic link, edit the link target directly; the UI can read the file but cannot save it.

Test a connection

Select Test to check the current editor contents without saving them. The action is available only when the backend advertises testing for the selected provider.
  • Mage renders Jinja expressions such as {{ env_var('POSTGRES_PASSWORD') }} using current runtime values.
  • Tests stop after 10 seconds, and only one test can run per project at a time.
  • Most tests open and close a connection without previewing, extracting, or writing data. Success confirms only that lightweight check.
  • Trino also runs SELECT 1 and requires catalog, host, and user configuration.
  • Mage shows specific configuration errors after redacting known secrets. Provider and driver exceptions use the generic connection-failure message.

Workflow checklist

When you validate a workspace manually, check the main profile lifecycle rather than editing io_config.yaml directly:
  1. Add a profile, choose a provider, edit its YAML, test when available, and save.
  2. Reload and confirm the profile persists, credentials are masked, and unchanged masks preserve saved values.
  3. Save two providers in one profile and confirm each keeps its own configuration.
  4. Clear one provider, save, and confirm unrelated provider keys remain.
  5. Confirm invalid YAML, mixed provider keys, stale revisions, read-only access, and delete confirmation block unsafe writes.

Using io_config in Your Code

SQL Block Example

In SQL blocks, you can select the desired IO Config profile from the UI using the “Profile” dropdown menu. For detailed information about configuring SQL blocks, see the SQL Blocks documentation.

Python Block Examples

You can use io_config in your Python code with different profile selection strategies: Basic Profile Usage:
Dynamic Profile Selection:
Environment-based Profile Selection:

Databases using io_config.yaml

The following database and storage integrations use io_config.yaml for credentials and connection settings. See each doc for the exact keys and examples: Relational & SQL databases Cloud data warehouses & analytics Storage & data lakes Other databases & services Vector stores & search

Best Practices

  1. Security:
    • Never commit sensitive credentials directly in the io_config file
    • Use environment variables or secret variables for sensitive information
    • Consider using a secrets management service for production environments
  2. Organization:
    • Use meaningful profile names
    • Group related configurations together
    • Document any non-standard configurations
    • Use the standard format for new configurations
  3. Version Control:
    • Add io_config.yaml to your .gitignore file
    • Provide a template file (io_config.yaml.template) with dummy values
    • Document the required environment variables

Troubleshooting

Common Issues & Solutions

1. “FileNotFoundError” or “No such file or directory”
  • Make sure your io_config.yaml file exists in your project root (e.g., /home/src/your_mage_project/io_config.yaml).
  • If running in a different environment (e.g., Docker), confirm the file is mounted and accessible.
2. “KeyError” or “Missing profile”
  • Double-check that the profile name you are referencing in your code (e.g., 'default', 'staging') exists in your io_config.yaml.
  • Profile names are case-sensitive.
3. “Missing required field” or “NoneType” errors
  • Ensure all required fields for your data source/destination are present in the selected profile.
4. “Environment variable not set”
  • If you use {{ env_var('VAR_NAME') }} in your config, make sure the environment variable is set in deployment environment.
  • You can check this by running echo $VAR_NAME in Mage terminal.
5. YAML syntax errors
  • Use a YAML linter or validator to check for indentation or formatting issues.
  • Strings containing special characters (like : or {}) should be quoted.
6. “Invalid credentials” or authentication failures
  • Double-check your credentials and permissions.
  • For cloud services, ensure your service account or IAM user has the necessary roles.
7. “Cannot import ConfigFileLoader” or similar import errors
  • Make sure you are importing from mage_ai.io.config (not mage_ai.io.io_config).
  • Example:
8. “Profile not selected” in SQL blocks
  • In the Mage UI, select the correct profile from the “Profile” dropdown before running your SQL block.
If you continue to have issues, ask for help in the Mage community Slack.

Additional Resources