airflow dag missing from UI after deploy, import failed
Troubleshoots DAGs that vanish from the Airflow UI after a deploy: import errors, dagbag parsing, and the difference between scheduler and webserver views. Use when a DAG was visible before the deploy and is gone now. Not for DAGs that never appeared in the first place.
TL;DR
A DAG disappears from the UI when the scheduler can no longer import its file: an import error, a new dependency missing on the scheduler, or a syntax error introduced by the deploy. Check the scheduler logs for the dag file's import error first; the webserver only shows what the scheduler successfully parsed. Fix the import, and the DAG comes back on the next parse cycle.
airflow dag missing from UI after deploy, import failedUse this when
- A DAG that was visible is gone from the UI right after a deploy.
- The scheduler log mentions an import error for the DAG file.
- Only some DAGs are missing while others still show.
Not for this skill when
- The DAG never appeared. Check the file location and filename pattern first.
- The DAG shows but will not run. That is a scheduling or pause-state issue.
Steps
- Search the scheduler logs for the DAG filename and read the full traceback. Note the exact import error and line. Verify: you have the real error, not a guess
- Reproduce the import on the scheduler host with python -c 'import' on the file, using the same environment. Note it fails the same way. Verify: the environment mismatch is proven
- Fix the import: install the missing dependency, correct the syntax, or guard the import so DAG parsing never runs heavy code. Note the file imports cleanly standalone. Verify: parsing succeeds in isolation
- Wait one dagdirlist_interval cycle or restart the scheduler, then confirm the DAG is back in the UI. Note the import-errors page is empty for that file. Verify: the UI reflects the fixed parse
- Add a CI step that imports every DAG file before deploy. Note the next bad deploy is caught before it ships. Verify: deploys stop breaking the UI
Variant phrasings
airflow dag not showing in UI
The general symptom search.
airflow import error dagbag
The log-shaped phrasing.
Compatibility: Airflow 2.x. DAG parsing behavior is the same across executors; the import-errors page lives under Browse in the UI.
Why it happens
The webserver renders DAGs from the metadata database, and the scheduler only writes rows for files it can import. One bad import in a deploy poisons that file's entry and the DAG vanishes. The confusing part is that the webserver and scheduler can run different code or dependencies, so the file works on your laptop and fails on the scheduler. The scheduler log is the source of truth, not the UI.
Edge cases / pitfalls
- A top-level variable or API call in the DAG file runs at parse time. Keep DAG files import-light or one slow dependency takes down parsing.
- .airflowignore and file extensions matter: a file renamed to .py.txt or excluded by ignore rules silently disappears with no error.
- In containerized deploys the scheduler image and webserver image can drift. Pin them to the same build.
- A DAG that imports fine but defines no DAG object at top level also vanishes. The file must assign a DAG at module scope.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstJuDJcRanWcJ4pQyEhn-9w