MWAA Airflow connection not defined


I get the following error when Airflow tries to import my DAG file on MWAA:

Broken DAG: [/usr/local/airflow/dags/] Traceback (most recent call last):
  File "/usr/local/airflow/.local/lib/python3.11/site-packages/airflow/hooks/", line 72, in get_connection
    conn = Connection.get_connection_from_secrets(conn_id)
  File "/usr/local/airflow/.local/lib/python3.11/site-packages/airflow/models/", line 477, in get_connection_from_secrets
    raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.exceptions.AirflowNotFoundException: The conn_id `test` isn't defined

However, the connection was clearly defined in the Web UI:

Enter image description here

We try to access the connection like this in the DAG file:

from airflow.providers.mysql.hooks.mysql import MySqlHook
mysql_hook = MySqlHook(mysql_conn_id='test')

Locally, in our Airflow development environment everything works fine, so we can exclude any issues related to the code.

1 Answer

The name of the parameter is conn_id[1] not mysql_conn_id --the latter is the example string[2].

mysql_hook = MySqlHook(conn_id='test')



answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions