On this page
- What does an Airflow server need?
- How do you prepare Python and PostgreSQL?
- How do you install Airflow with the constraint file?
- How do you configure the database, executor and login?
- How do you run Airflow under systemd?
- How do you publish the UI over HTTPS?
- How do you write and test a first DAG?
- How do you upgrade and maintain Airflow?
- Where do you look when Airflow misbehaves?
- Questions
What does an Airflow server need?
A single Airflow host needs Python 3.10 or newer, a PostgreSQL database for its metadata and at least 4 GB of memory once the scheduler, the web API and a few task processes run together. Airflow 3 split the old monolith into several long running processes:
- api-server: serves the web UI and the REST API on port 8080 (it replaced the old
webservercommand). - scheduler: decides which task instances are due and hands them to the executor.
- dag-processor: parses your DAG files; in Airflow 3 it is a separate process you must run.
- triggerer: handles deferred tasks such as sensors that wait on external events.
On one VPS the LocalExecutor runs tasks as child processes, which keeps the setup small. Ubuntu 24.04 ships Python 3.12, Debian 12 ships 3.11, Debian 13 ships 3.13 and Rocky Linux 9 or AlmaLinux 9 offer a python3.12 package. Log in as your sudo user first, as shown in your first SSH session.
How do you prepare Python and PostgreSQL?
Install the interpreter, the venv module, build tools for packages with C extensions and PostgreSQL from the distribution repositories.
# Ubuntu and Debian
sudo apt update
sudo apt install -y python3 python3-venv python3-dev build-essential libpq-dev postgresql
# Rocky Linux 9 and AlmaLinux 9
sudo dnf install -y python3.12 python3.12-devel gcc libpq-devel postgresql-server
sudo postgresql-setup --initdb
sudo systemctl enable --now postgresqlCreate a database and a login role for Airflow. Pick your own long password.
sudo -u postgres psql -c "CREATE ROLE airflow LOGIN PASSWORD 'Change-This-Secret';"
sudo -u postgres psql -c "CREATE DATABASE airflow OWNER airflow;"On Rocky and Alma the default pg_hba.conf uses ident for local TCP logins. Change the two host lines for 127.0.0.1/32 and ::1/128 to scram-sha-256 and restart PostgreSQL, otherwise Airflow cannot log in with the password. The PostgreSQL guide covers tuning and backups in more depth.
How do you install Airflow with the constraint file?
Install Airflow with pip inside a virtual environment owned by your user, always together with the constraint file for your exact Airflow and Python versions. The constraint file pins hundreds of dependencies to a combination the project tested, which is what keeps a plain pip install from pulling incompatible libraries.
python3 -m venv ~/airflow-venv # use python3.12 on Rocky and Alma
source ~/airflow-venv/bin/activate
pip install --upgrade pip
AIRFLOW_VERSION=3.1.3 # set this to the current release on PyPI
PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
CONSTRAINTS="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
pip install "apache-airflow[postgres]==${AIRFLOW_VERSION}" apache-airflow-providers-fab --constraint "${CONSTRAINTS}"
airflow versionIf pip reports that the constraint URL returns 404, that release does not support your Python version yet; check the supported versions in the installation notes for that release and use a newer interpreter. Avoid installing Airflow with sudo pip or into the system Python, because distribution upgrades would then break it.
How do you configure the database, executor and login?
Airflow reads settings from ~/airflow/airflow.cfg or from environment variables named AIRFLOW__SECTION__KEY. Environment variables in one file are easier to share between the systemd units, so create ~/airflow/airflow.env:
mkdir -p ~/airflow/dags
cat > ~/airflow/airflow.env <<'EOF'
AIRFLOW_HOME=/home/deploy/airflow
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:Change-This-Secret@127.0.0.1:5432/airflow
AIRFLOW__CORE__EXECUTOR=LocalExecutor
AIRFLOW__CORE__LOAD_EXAMPLES=False
AIRFLOW__CORE__AUTH_MANAGER=airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager
AIRFLOW__API__SECRET_KEY=replace-with-random-string-1
AIRFLOW__API_AUTH__JWT_SECRET=replace-with-random-string-2
EOF
chmod 600 ~/airflow/airflow.envGenerate the two secrets with openssl rand -hex 32. The JWT secret must be identical for every component, otherwise tasks fail with signature errors when the scheduler and the API server each invent their own key. The FAB auth manager gives you real user accounts with roles; the default simple auth manager is meant for local testing. Load the file and build the schema:
set -a; source ~/airflow/airflow.env; set +a
airflow db migrate
airflow users create --username deploy --role Admin --firstname Ops --lastname Admin --email ops@example.net --password 'Another-Long-Secret'How do you run Airflow under systemd?
Give each component its own unit so systemd restarts it independently. A template unit keeps the four services identical apart from the subcommand:
sudo tee /etc/systemd/system/airflow@.service >/dev/null <<'EOF'
[Unit]
Description=Airflow %i
After=network-online.target postgresql.service
Wants=network-online.target
[Service]
User=deploy
Group=deploy
EnvironmentFile=/home/deploy/airflow/airflow.env
ExecStart=/home/deploy/airflow-venv/bin/airflow %i
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
for c in api-server scheduler dag-processor triggerer; do sudo systemctl enable --now airflow@$c; done
systemctl status 'airflow@*' --no-pager
ss -tlnp | grep 8080By default the API server listens on all interfaces. Add AIRFLOW__API__HOST=127.0.0.1 to the env file and restart airflow@api-server once the reverse proxy is in place, so the UI is only reachable over HTTPS.
How do you publish the UI over HTTPS?
Put a reverse proxy with a certificate in front of port 8080 and keep 8080 closed in the firewall. With Caddy, one site block is enough:
airflow.example.net {
reverse_proxy 127.0.0.1:8080
}The Caddy HTTPS tutorial shows the install and certificate steps, and the Nginx reverse proxy guide covers the same job with Nginx. Then open only SSH and the web ports:
# Ubuntu and Debian
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable
# Rocky and Alma
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadHow do you write and test a first DAG?
A DAG is a Python file in the dags folder; Airflow 3 exposes its authoring interface under airflow.sdk. Save this as ~/airflow/dags/disk_report.py:
from datetime import datetime
from airflow.sdk import dag, task
@dag(schedule="@daily", start_date=datetime(2026, 1, 1), catchup=False, tags=["ops"])
def disk_report():
@task
def usage() -> str:
import shutil
total, used, free = shutil.disk_usage("/")
return f"{used / total:.0%} used"
@task
def log(msg: str):
print("Root filesystem:", msg)
log(usage())
disk_report()Check that it parses and run it once without the scheduler:
set -a; source ~/airflow/airflow.env; set +a
airflow dags list-import-errors
airflow dags test disk_reportThe DAG processor picks up the file within a minute or so, and it appears in the UI where you can unpause it.
How do you upgrade and maintain Airflow?
Upgrade by installing the new version with its own constraint file into the same virtual environment, then migrating the schema while the services are stopped.
for c in api-server scheduler dag-processor triggerer; do sudo systemctl stop airflow@$c; done
sudo -u postgres pg_dump airflow > ~/airflow-before-upgrade.sql
# repeat the pip install line with the new AIRFLOW_VERSION
airflow db migrate
for c in api-server scheduler dag-processor triggerer; do sudo systemctl start airflow@$c; doneTask logs grow under ~/airflow/logs; prune old ones with a cron job or the airflow db clean command for metadata older than a chosen date. The optional daily backup add-on covers the whole disk, and the backups tutorial adds file level copies with restic.
Where do you look when Airflow misbehaves?
Most problems show up in the journal of one component, so read the one that matches the symptom.
- DAG missing from the UI: run
airflow dags list-import-errorsandjournalctl -u airflow@dag-processor -n 50. - Tasks stuck in queued: the scheduler or executor is down; check
journalctl -u airflow@scheduler. - Invalid token or signature errors: the JWT secret differs between components; make sure every unit reads the same env file.
- Out of memory: lower
AIRFLOW__CORE__PARALLELISMor move to a larger plan as in moving to a larger plan.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Apache Airflow workflows
Can I use SQLite instead of PostgreSQL?
SQLite only works with the sequential executor for experiments. Any schedule you depend on should use PostgreSQL (or MySQL) with LocalExecutor.
Is airflow standalone enough for a server?
The airflow standalone command starts every component in one terminal with a generated admin password. It is handy for a quick look, but systemd units with PostgreSQL survive reboots and crashes.
How much memory does Airflow need?
Plan on 4 GB for the components plus whatever your tasks use. Heavy data work inside tasks needs more; sizing it to the largest task is the safe rule.
Where do I keep connection passwords for my tasks?
Store them as Airflow connections or variables in the UI or with airflow connections add, not in DAG files, so the code can live in Git without secrets.
Can I deploy DAGs with Git?
Yes. Clone the repository into the dags folder and pull it from a cron job or CI pipeline, for example with a CI runner on the same server.