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:

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