Skip to content

DAG execution fails with 'state mismatch' error when behind an NGINX reverse proxy #54545

@gx8066liren

Description

@gx8066liren

Apache Airflow version

3.0.4

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Description of the bug

When Airflow is running behind an NGINX reverse proxy, manually triggering a DAG from the web UI results in a task failure. The logs indicate a state mismatch error, where the LocalExecutor reports the task as failed, but the task instance's state remains queued. This issue seems to be related to the reverse proxy configuration, as the DAG runs correctly when accessing the webserver directly.

Environment

Airflow version: 3.0.4
OS: CentOS 7
Python version: 3.10
Executor: LocalExecutor
Deployment: airflow standalone running inside a Docker container.

Expected behavior

The DAG should be triggered and execute successfully, with task states updating correctly in the UI and logs.

Actual behavior

The DAG run fails. The task instance logs show the following state mismatch error:
Executor LocalExecutor(parallelism=32) reported that the task instance <TaskInstance: generate_hot_question_dag.generate_hot_question_task scheduled__2025-08-14T22:00:00+00:00 [queued]> finished with state failed, but the task instance's state attribute is queued. Learn more: https://airflow.apache.org/docs/apache-airflow/stable/troubleshooting.html#task-state-changed-externally

Relevant Configurations

NGINX Configuration:

map $http_upgrade $connection_upgrade {
    default Upgrade;
    ''      keep-alive;
}

location /scheduler/ {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_redirect off;
}

Airflow Environment Variable:
AIRFLOW__API__BASE_URL=http://localhost/scheduler

Screenshots

Image Image

What you think should happen instead?

No response

How to reproduce

  1. Run Airflow using the airflow standalone command within a Docker container.
  2. Configure an NGINX reverse proxy to forward requests from a subpath (e.g., /scheduler/) to the Airflow webserver (e.g., http://127.0.0.1:8080).
  3. Set the base_url in the Airflow configuration to match the proxy path by setting the environment variable: AIRFLOW__API__BASE_URL=http://localhost/scheduler.
  4. Access the Airflow UI via the NGINX proxy URL.
  5. Manually trigger any DAG.

Operating System

CentOS 7

Versions of Apache Airflow Providers

apache-airflow-providers-common-compat==1.7.3
apache-airflow-providers-common-io==1.6.2
apache-airflow-providers-common-sql==1.27.5
apache-airflow-providers-smtp==2.2.0
apache-airflow-providers-standard==1.5.0

Deployment

Docker-Compose

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions