Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mysql): treat host-not-privileged (1130) as non-retryable (#64606)

Tom Owersaffd98e453a5
diff --git a/posthog/temporal/data_imports/sources/mysql/source.py b/posthog/temporal/data_imports/sources/mysql/source.py
index 01c4a1b1e384..5e1a3ca3a2fc 100644
--- a/posthog/temporal/data_imports/sources/mysql/source.py
+++ b/posthog/temporal/data_imports/sources/mysql/source.py
@@ -192,6 +192,12 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# text is translated on non-English servers) so it catches both the raw pymysql string and
# the Temporal-wrapped `OperationalError: (1054, ...)` form.
'(1054, "Unknown column': "A column referenced during sync no longer exists in your source table (MySQL error 1054). This usually means a column was renamed or dropped — if it's the table's incremental field, update it to a column that exists (or switch to a full re-sync), then resync.",
+ # MySQL/MariaDB error 1130 (ER_HOST_NOT_PRIVILEGED): the server has no grant permitting
+ # PostHog's connecting host, so the handshake is rejected before any credentials are
+ # checked. Only a DB admin can fix this server-side (GRANT for the host, or allow our
+ # egress / SSH-tunnel host) — retrying connects from the same host fails identically.
+ # Match the stable tail phrase, not the volatile host in the message prefix.
+ "is not allowed to connect to this MySQL server": "Your MySQL/MariaDB server isn't allowing connections from PostHog's host (error 1130). Ask your database admin to grant access for the connecting host (or allow our IP / SSH-tunnel host), then retry the sync.",
}
def reconcile_schema_metadata(
diff --git a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
index 5186c210292b..2b0e97384570 100644
--- a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
+++ b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
@@ -1214,6 +1214,25 @@ class TestMySQLSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"Invalid-view error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ # Raw pymysql str(error) form.
+ str(
+ pymysql.err.OperationalError(
+ 1130,
+ "Host 'ec2-52-4-194-122.compute-1.amazonaws.com' is not allowed to connect to this MySQL server",
+ )
+ ),
+ # Temporal-wrapped str(e.cause) form — different host, same stable phrase.
+ "OperationalError: (1130, \"Host '10.0.1.5' is not allowed to connect to this MySQL server\")",
+ ],
+ )
+ def test_host_not_privileged_is_non_retryable(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
+ assert is_non_retryable, f"Host-not-privileged error should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[