How to Fix MySQL Error 1130 (ER_HOST_NOT_PRIVILEGED)

Published
Length
3 min read

Luis Felipe Dias

All posts

The database returns mysql error 1130 when a client IP or host lacks permission to log in. You fix it by matching the user account host rule to the client network address. This failure uses the official symbol ER_HOST_NOT_PRIVILEGED and SQLSTATE HY000. The server sends the message that the host is not allowed to connect to this MySQL server. The database blocks the client before it even checks the password. Your team must check both user grant tables and network paths to clear this block. Wha

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

The database returns mysql error 1130 when a client IP or host lacks permission to log in. You fix it by matching the user account host rule to the client network address.

This failure uses the official symbol ER_HOST_NOT_PRIVILEGED and SQLSTATE HY000. The server sends the message that the host is not allowed to connect to this MySQL server. The database blocks the client before it even checks the password. Your team must check both user grant tables and network paths to clear this block.

What causes mysql error 1130 in production

MySQL identifies every user by both a username and a source host. An account for a user on localhost is separate from that same user on a remote IP. If the incoming client IP does not match any host entry, the server drops the attempt.

Local accounts are a top cause for this error during app setup. New database setups often restrict the root user and default accounts to the local machine. When an app server tries to log in over the network, the database rejects the host.

Network translation also triggers this error in cloud setups. A container, load balancer, or NAT gateway often changes the source IP of the client traffic. The database sees the gateway IP instead of the app server IP. If the user role only allows the app server IP, the login fails.

DNS lookup mismatches cause this problem as well. By default, the database server may try to resolve the client IP into a hostname. If reverse DNS fails or returns an unexpected name, the host check fails right away.

How to diagnose and fix the host block

Start by checking the exact host name or IP address inside the error message. That string shows the exact source address that the database server sees on the network. Compare that address against the user table on the database server.

Privileged Access Management (PAM) + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Log in to the database from a local shell or an allowed admin host. Check the list of user accounts and their linked host values in the system schema. Look for the user account that your app or client uses to log in.

If the user is bound only to localhost, create or update the user for the remote IP. Use the specific private IP or narrow subnet of your app tier. Reload the grant tables if you change system tables directly, or use standard user management statements.

Check your server DNS settings if the error message shows a strange hostname instead of an IP. When the server skips name resolution, it matches client logins by IP address alone. Make sure your user host rules use IP addresses before you turn off DNS lookups.

How to prevent host errors without broad wildcards

Many teams try to fix this error fast by setting the user host to a wildcard. A full wildcard lets that user log in from any network address on the planet. That choice creates a major security risk if a password leaks.

Instead, limit user host rules to specific app subnets or fixed routing endpoints. Route developer and tool traffic through a single controlled point with a static IP. The database then only needs to trust that one fixed address. You can also apply data masking to rewrite emails, phone numbers, and card numbers in query results.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.

First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.

Frequently asked questions

What does ER_HOST_NOT_PRIVILEGED with SQLSTATE HY000 mean?

It means the MySQL server blocked the network connection before checking user credentials. The client IP or hostname does not match any allowed host in the database grant tables.

Why does my app get mysql error 1130 when my local shell works?

Your local shell logs in through a local socket or loopback address that the user account allows. Your app logs in over the network from an IP address that lacks a matching user rule.

Is it safe to use the percent wildcard to fix host errors?

Using a broad wildcard on public or shared networks is unsafe because any host can attempt a login. Always bind accounts to a private subnet or route logins through a single trusted address.

The query runs. The emails stay hidden.