IO Config Setup Guide
Theio_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
Theio_config file should be stored in your Mage project’s root directory. The default path is:
Creating a New io_config File
1. Basic Structure
Create a new file namedio_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 theio_config file:
Standard Format (Recommended)
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: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):
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 testio_config.yaml profiles from the Mage UI:
- Open Settings.
- In Workspace, select Data connections.
- Select an existing profile or choose Add profile. You can also open
/settings/workspace/io-configdirectly.
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.
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 fullio_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 1and 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 editingio_config.yaml directly:
- Add a profile, choose a provider, edit its YAML, test when available, and save.
- Reload and confirm the profile persists, credentials are masked, and unchanged masks preserve saved values.
- Save two providers in one profile and confirm each keeps its own configuration.
- Clear one provider, save, and confirm unrelated provider keys remain.
- 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 useio_config in your Python code with different profile selection strategies:
Basic Profile Usage:
Databases using io_config.yaml
The following database and storage integrations useio_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
-
Security:
- Never commit sensitive credentials directly in the
io_configfile - Use environment variables or secret variables for sensitive information
- Consider using a secrets management service for production environments
- Never commit sensitive credentials directly in the
-
Organization:
- Use meaningful profile names
- Group related configurations together
- Document any non-standard configurations
- Use the standard format for new configurations
-
Version Control:
- Add
io_config.yamlto your.gitignorefile - Provide a template file (
io_config.yaml.template) with dummy values - Document the required environment variables
- Add
Troubleshooting
Common Issues & Solutions
1. “FileNotFoundError” or “No such file or directory”- Make sure your
io_config.yamlfile 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.
- Double-check that the profile name you are referencing in your code (e.g.,
'default','staging') exists in yourio_config.yaml. - Profile names are case-sensitive.
- Ensure all required fields for your data source/destination are present in the selected profile.
- 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_NAMEin Mage terminal.
- Use a YAML linter or validator to check for indentation or formatting issues.
- Strings containing special characters (like
:or{}) should be quoted.
- Double-check your credentials and permissions.
- For cloud services, ensure your service account or IAM user has the necessary roles.
- Make sure you are importing from
mage_ai.io.config(notmage_ai.io.io_config). - Example:
- In the Mage UI, select the correct profile from the “Profile” dropdown before running your SQL block.