How to Fix DAG Not Showing in UI in Airflow
DAG is not showing in the Airflow UI, first check that the DAG file is placed in the correct dags_folder and has no syntax errors. Also, ensure the DAG is not paused and the start_date is set correctly so Airflow can schedule it.Why This Happens
This issue usually happens because Airflow cannot parse the DAG file due to syntax errors, the DAG file is not in the right folder, or the DAG's start_date is set in the future. Another common cause is that the DAG is paused or has schedule_interval=None without manual triggering.
from airflow import DAG from airflow.operators.dummy import DummyOperator from datetime import datetime # Broken DAG with syntax error (missing colon) default_args = { 'start_date': datetime(2024, 1, 1) } dag = DAG('example_dag', default_args=default_args, schedule_interval='@daily') start = DummyOperator(task_id='start', dag=dag) end = DummyOperator(task_id='end', dag=dag) start >> end # Missing colon below causes syntax error if __name__ == '__main__': print('Run DAG')
The Fix
Fix the syntax errors in your DAG file and make sure it is saved in the correct dags_folder. Set the start_date to a past date and confirm the DAG is unpaused in the UI. Also, verify the DAG file loads without errors by checking Airflow logs.
from airflow import DAG from airflow.operators.dummy import DummyOperator from datetime import datetime default_args = { 'start_date': datetime(2024, 1, 1) } dag = DAG('example_dag', default_args=default_args, schedule_interval='@daily') start = DummyOperator(task_id='start', dag=dag) end = DummyOperator(task_id='end', dag=dag) start >> end if __name__ == '__main__': print('Run DAG')
Prevention
Always validate your DAG files with airflow dags list or airflow dags test commands before deploying. Keep your start_date in the past and avoid setting it dynamically to future dates. Use version control and CI pipelines to catch syntax errors early. Regularly check Airflow scheduler and webserver logs for parsing errors.
Related Errors
- DAG not found error: Happens if DAG ID is misspelled or DAG file is missing.
- Scheduler not running: DAGs won't appear if the scheduler service is down.
- Import errors: External library issues can prevent DAG parsing.