Skip to content
MySQL

MySQL Error 1130

Host is not allowed to connect to this MySQL server

Applies to: MySQL 5.7, 8.0 and 8.4
Last technically reviewed 24 October 2026 on MySQL 8.0.46
The full message
ERROR 1130 (HY000): Host '203.0.113.25' is not allowed to connect to this MySQL server
Other forms of this message
Client host shown by name (when the server resolves it)
ERROR 1130 (HY000): Host 'web01.example.com' is not allowed to connect to this MySQL server
PHP PDO
SQLSTATE[HY000] [1130] Host '203.0.113.25' is not allowed to connect to this MySQL server
Error number
1130
SQLSTATE
HY000
Symbol
ER_HOST_NOT_PRIVILEGED
Product
MySQL Server
Versions
MySQL 5.7, 8.0 and 8.4
Last reviewed
24 October 2026

What it means

Error 1130 means the server has no account at all whose host part matches the address the client connects from, so it refused the connection before asking for a user name or password.

Every MySQL account has a host part, such as 'app'@'localhost' or 'app'@'10.0.0.%'. When a client connects, the server first checks whether any account allows connections from the client's host. If none does, it returns 1130 straight away and, as the Performance Schema documentation puts it, does not even ask for a user name or password. That makes 1130 different from 1045, where some account matches the host but the user name or password does not authenticate.

The good news hidden in 1130 is that the network works: the client reached the server, the port is open and the server is listening (otherwise you would get 2003). The host in the message is the address, or resolved name, that the server sees, which can differ from the client's own idea of its address when there is NAT, a proxy, a container network or a VPN in between. Use exactly that value when deciding which account host to allow.

Common causes

  • The accounts exist only for local connections, such as the default 'root'@'localhost', and a client connects from another machine.
  • The account was created for one address or subnet and the client now comes from another (a new application server, a changed IP, a container or cloud network with different addresses).
  • NAT, a proxy or a VPN means the server sees a different source address than the client expects.
  • The account host is a host name, but the server cannot resolve the client to that name, or runs with skip_name_resolve ON, in which case only IP addresses and localhost can match.

Diagnose it

Read-only These statements only read metadata (information_schema, performance_schema and SHOW statements) or your own data. They do not change data, privileges or configuration, so they are safe to run first.

Which hosts do the accounts allow?

Run as an administrator on the server (for example over SSH with a local connection).

SELECT user, host
FROM mysql.user
WHERE user = 'app'
ORDER BY host;

SELECT DISTINCT host
FROM mysql.user
ORDER BY host;
What to look for

The host patterns for the application's account, and every host pattern in use. If none of them matches the host in the error (an exact name or IP, a pattern with % or _, or a netmask or CIDR form), the server has nothing to match the client with.

Which client hosts have been refused?

SELECT ip, host, host_validated, count_host_acl_errors, first_error_seen, last_error_seen
FROM performance_schema.host_cache
WHERE count_host_acl_errors > 0
ORDER BY last_error_seen DESC;
What to look for

count_host_acl_errors counts connections refused because no user is allowed from that host. The ip and host columns show the address and resolved name exactly as the server sees them. The host cache covers remote TCP clients only, not loopback or socket connections.

Does the server match host names or only IP addresses?

SHOW VARIABLES LIKE 'skip_name_resolve';
SHOW VARIABLES LIKE 'bind_address';
What to look for

With skip_name_resolve ON, account hosts must be IP addresses (or localhost); host names in mysql.user never match remote clients. bind_address confirms which interfaces accept connections.

How often has 1130 been raised?

SELECT error_number, error_name, sum_error_raised, first_seen, last_seen
FROM performance_schema.events_errors_summary_global_by_error
WHERE error_number = 1130;
What to look for

The count since the server started and when it was last raised. A count that jumps after a deployment or network change points to a new client address.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Create an account for the real client host, with least privilege

Changes permissions

Take the host from the error message or the host cache and create an account for that address or its subnet, granting only what the application needs on its own database.

Caution: Do not create accounts for '%' (any host) to make the error go away, and never give an application account GRANT ALL ON *.*. The MySQL manual warns that leaving '%' in place leaves the system insecure; use the narrowest address pattern that covers your clients.

CREATE USER 'app'@'10.0.0.%' IDENTIFIED BY 'a-long-random-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'app'@'10.0.0.%';

Change the host part of an existing account

Changes permissions

When the application has moved and the old address is no longer used, rename the account so its privileges move with it.

Caution: Clients still connecting from the old host start failing at once. Check the host cache or connection logs for the old address before renaming.

RENAME USER 'app'@'10.0.0.15' TO 'app'@'10.0.1.%';

Administer from an allowed host instead of opening root

Client or network side

For administration, connect from a host that already has an account, or tunnel through the server so the connection is local: ssh -L 3307:127.0.0.1:3306 admin@db.example.com, then mysql -h 127.0.0.1 -P 3307 -u root -p. Keep root limited to localhost.

Use IP-based host parts when name resolution is off or unreliable

Changes permissions

If skip_name_resolve is ON, or DNS for the clients is unreliable, create the account for the IP address or subnet rather than a host name; the MySQL manual recommends IP addresses in the grant tables for DNS problems.

Examples

Connecting as root from another machine

Shown as documented in the MySQL reference manual (Troubleshooting Problems Connecting to MySQL); not reproduced here, because it needs a connection from a second host, or account changes, and the lab may not create accounts.

-- On the server, root exists only for local connections:
SELECT user, host FROM mysql.user WHERE user = 'root';  -- root | localhost

-- From another machine (203.0.113.25):
-- mysql -h db.example.com -u root -p
Result
ERROR 1130 (HY000): Host '203.0.113.25' is not allowed to connect to this MySQL server

An application server whose address is not covered by the account

Shown as documented in the MySQL reference manual (no user table row with a Host value that matches the client host); not reproduced here, because it needs a second client host and the lab may not create accounts. The PDO form follows the connection error format we observed for 1045 and 2002.

-- The account allows one subnet only:
SELECT user, host FROM mysql.user WHERE user = 'app';  -- app | 192.168.1.%

-- The application now runs in a container network and connects from 172.17.0.5:
-- new PDO('mysql:host=db.example.com;dbname=shop', 'app', $password);
Result
SQLSTATE[HY000] [1130] Host '172.17.0.5' is not allowed to connect to this MySQL server

How to prevent it

Plan the host part with the network: decide which subnets the application servers use, create the accounts for those patterns at deployment time, and update them as part of any network or hosting change. Prefer IP or subnet patterns, which do not depend on DNS, and keep administrative accounts limited to localhost or a management subnet.

Watch for refused hosts: count_host_acl_errors in performance_schema.host_cache and error 1130 in events_errors_summary_global_by_error show new client addresses (or scanning) before users report them.

Common questions

How do I fix Host is not allowed to connect to this MySQL server?

Create an account for the host shown in the message (or its subnet) with only the privileges the application needs, or connect from a host that already has one. Do not open root or any account to '%'.

Do I need to change bind_address to fix 1130?

No. If you got 1130, the server is already listening and reachable on the network. bind_address problems give connection errors such as 2003 instead. 1130 is only about accounts and their host part.

Is it safe to create a user with host %?

It allows that user name from any address, so it is rarely the right choice. The MySQL manual suggests % only temporarily, to discover the real client host with SELECT USER(), and then replacing it with that host. Use a specific address or subnet pattern.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on MySQL 8.0.46. Message templates checked against the server's error catalogue (perror) for that version.

Still stuck on a MySQL error?

Browse the full MySQL error library, or get hands-on help from an experienced SQL professional.