Skip to main content

How to Set AIRFLOW_HOME for Apache Airflow®

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Apache Airflow® keeps everything it creates in one folder: its settings file, its database, its logs and the admin password. Unless you tell it otherwise, that folder is ~/airflow in your home folder, shared by every project. The AIRFLOW_HOME environment variable points Airflow at a folder of your choice instead. This guide shows both, on Airflow 3.4.0.

Syntax​

Syntax
export AIRFLOW_HOME=<folder>
PartWhat it means
exportSets an environment variable for this terminal and every program you start from it
AIRFLOW_HOMEThe variable Airflow reads to find its folder
<folder>The folder to use. "$PWD" means the folder you're in, which is usually your project

Airflow's Quick Start: "Airflow keeps its files in ~/airflow unless you set AIRFLOW_HOME."

Prerequisites​

  • Apache Airflow® installed in a virtual environment, and that environment activated. Check with airflow version.

Step 1: See What Happens Without It​

In a terminal where AIRFLOW_HOME isn't set, ask Airflow where it looks for Dags:

Terminal
echo "AIRFLOW_HOME=$AIRFLOW_HOME"
airflow config get-value core dags_folder
ls ~/airflow
Output
AIRFLOW_HOME=
/Users/you/airflow/dags
airflow.cfg logs

The terminal: AIRFLOW_HOME is empty, airflow config get-value core dags_folder prints /Users/you/airflow/dags, and ls ~/airflow shows airflow.cfg and logs.

The variable is empty, so Airflow used ~/airflow. That one command was enough for it to create the folder, with a new airflow.cfg and a logs folder in it. (I left out the two FileType is deprecated warnings that every command prints on Python 3.14.)

Step 2: Point It at Your Project​

In your project folder:

Terminal
export AIRFLOW_HOME="$PWD"
echo "AIRFLOW_HOME=$AIRFLOW_HOME"
airflow config get-value core dags_folder
ls
Output
AIRFLOW_HOME=/Users/you/source/airflow-home-demo
/Users/you/source/airflow-home-demo/dags
airflow.cfg logs

The terminal after export AIRFLOW_HOME="$PWD": the variable shows the project folder, the Dags folder is inside it, and ls shows airflow.cfg and logs in the project.

Now everything is in the project: the Dags folder is dags inside it, and Airflow created its own airflow.cfg and logs there. The quotes around "$PWD" keep a folder name with spaces in one piece.

Step 3: Set It Again in Every New Terminal​

export only lasts as long as the terminal. Open a new one and check:

Terminal
echo "AIRFLOW_HOME=$AIRFLOW_HOME"
Output
AIRFLOW_HOME=

A new terminal where echo prints AIRFLOW_HOME= with nothing after it.

It's empty again. Every time you open a terminal for this project, go to its folder and run the export line before any airflow command. Airflow's Quick Start warns why: a terminal without it uses ~/airflow, "with a separate database and password".

Common Mistakes​

MistakeWhat happensDo this instead
Setting it after the first airflow commandAirflow has already created ~/airflowExport it first; delete ~/airflow if you don't use it
AIRFLOW_HOME=$PWD without exportOnly that shell knows the variable; airflow doesn't see itUse export
Running the export in another folderAirflow uses that folder insteadcd into the project first
Forgetting it in a second terminalThat terminal's commands use ~/airflow and another databaseExport it in every terminal

Troubleshooting​

SymptomLikely causeFix
Your Dags or runs are suddenly missingThis terminal uses ~/airflow, not your projectecho $AIRFLOW_HOME, then export it
A ~/airflow folder you didn't createAn airflow command ran without the variableDelete it if you don't use it
The admin password doesn't workThe two folders have different passwordsRead the password file in the folder Airflow is using

FAQ​

Does Airflow create the folder?​

It creates its own files in it, airflow.cfg and logs, the first time a command needs them. ~/airflow itself was created when it didn't exist.

Can I put AIRFLOW_HOME somewhere other than the project?​

Yes, any folder works. Keeping it in the project means each project has its own settings and database.

Does this work in PowerShell?​

Airflow runs on Windows only inside WSL2, where you use bash and the same export line.

Conclusion​

Without AIRFLOW_HOME, airflow config get-value core dags_folder used ~/airflow and created it. With export AIRFLOW_HOME="$PWD", the same command used the project folder and created airflow.cfg and logs there, and a new terminal started out without the variable again.

Additional Resources​

Apache®, Apache Airflow and Airflow® are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.