# Airflow Connection

> A saved set of login details for an outside system. Tasks find it by name.

**Field:** Data Engineering  
**Category:** Orchestration  
**Also known as:** Connection (Airflow), conn_id, AIRFLOW_CONN

## Think of it like

It is like a saved contact on your phone. You tap a name, and the phone knows the number.

## Definition

An Airflow connection stores the details for reaching an outside system. It holds the host, the login, the password and the type of system. Each one has a short name, called its conn_id. Tasks and hooks ask for a connection by that name. So no password is written in the DAG file. Connections can be set in the web page, from the command line or in a variable named AIRFLOW_CONN_ and the name.

## Example

The shop's database is saved as a connection named shop_db. Every DAG that reads orders asks for shop_db. When the password changes, it changes in one place.

## Example code

```bash
export AIRFLOW_CONN_SHOP_DB='postgres://etl:secret@db.example.com:5432/shop'
```

A connection named shop_db, set in a variable. No DAG file holds it.

## Why it matters

Passwords stay out of the code and out of git. One change to a connection fixes every DAG that uses it.

## Common mistake

Writing the password straight into the DAG file. Anyone who can read the code can then read the password.

## Three principles

- **Stored once.** Host, login and password.
- **Found by name.** Tasks ask for the conn_id.
- **Out of the code.** No secrets in DAG files.

## Related terms

- [Airflow Hook](https://learn.benibix.com/term/data/airflow-hook)
- [Airflow Provider Package](https://learn.benibix.com/term/data/airflow-provider-package)
- [Airflow Operator](https://learn.benibix.com/term/data/airflow-operator)
- [Apache Airflow](https://learn.benibix.com/term/data/apache-airflow)
- [Airflow Metadata Database](https://learn.benibix.com/term/data/airflow-metadata-database)

![A connection box named shop_db holds the host, login and password outside the code. An arrow leads into a dashed box, the provider package apache-airflow-providers-postgres, which holds a highlighted hook that talks to Postgres and an operator, a ready-made task. An arrow leads on to the shop database outside Airflow.](https://learn.benibix.com/diagrams/dat2-airflow-integrations.svg)

---

Source: https://learn.benibix.com/term/data/airflow-connection
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
