MySQL Error 1130: Host Is Not Allowed to Connect
Fix MySQL Error 1130 by matching the client host to a MySQL user@host account and checking DNS, skip_name_resolve, and least-privilege grants.
On this page
MySQL Error 1130 (HY000, ER_HOST_NOT_PRIVILEGED) means the server rejected a connection from the client host. The message is usually Host '...' is not allowed to connect to this MySQL server. The MySQL 8.4 error reference lists this code and message.
The client reached a MySQL server, so first check which host the server sees and whether a MySQL account allows connections from it. Error 1130 is different from Error 1045, which reports an account authentication failure, and Error 1044, which occurs after connecting when the account lacks database privileges.
Identify the client host MySQL sees
Use the host named in the Error 1130 message. For an application, that host may be the application server, a container, or a NAT gateway—not the developer’s laptop or a browser. Ask the database administrator which source address reaches the database if a proxy or network translation is involved.
MySQL accounts are identified by both user and host, such as 'app_user'@'localhost' and 'app_user'@'app-server.example.com'. They are separate accounts. The server matches the incoming client host against the account’s host part; see the MySQL 8.4 guide to account names and connection verification.
Name resolution can affect that match. An administrator can check the setting with:
SHOW VARIABLES LIKE 'skip_name_resolve';
When skip_name_resolve is enabled, MySQL uses IP addresses rather than resolving client host names, so account host values must be configured accordingly. See the skip_name_resolve documentation. Local connections can also use different transports: on Unix-like systems, localhost commonly uses a socket, while 127.0.0.1 uses TCP; see MySQL’s connection transport documentation.
Check the account’s host entry
An administrator can list the host entries for the intended user:
SELECT User, Host
FROM mysql.user
WHERE User = 'app_user';
Compare the results with the client host in the error and the server’s name-resolution setting. If the application connects from a different host than expected, fix its connection route or configure a separate account for its actual, approved source host. Do not change a local account and assume that it also applies to a remote application server.
Create a host-specific account with limited privileges
If no account matches the approved application host, an administrator can create one for that host and grant only the operations the application needs. Replace the example host, database, and privileges with values for your environment:
CREATE USER 'app_user'@'app-server.example.com'
IDENTIFIED BY RANDOM PASSWORD;
GRANT SELECT, INSERT, UPDATE, DELETE
ON appdb.*
TO 'app_user'@'app-server.example.com';
MySQL returns the generated password once; store it directly in the application’s protected secret configuration. This avoids putting a cleartext password in a CREATE USER statement, which may be recorded in logs or client history. See the MySQL 8.4 CREATE USER documentation. For an existing account, inspect its definition and grants rather than creating a duplicate. Avoid granting access from every host or using GRANT ALL just to clear Error 1130. MySQL account host wildcards such as % are deprecated; prefer a specific host or a deliberately scoped network rule. See the MySQL 8.4 account-name rules and GRANT syntax.
After the connection succeeds, verify the account MySQL matched:
SELECT USER(), CURRENT_USER();
SHOW GRANTS;
USER() shows the client identity supplied at connection time; CURRENT_USER() shows the MySQL account used for privilege checks. If the error changes to 1044, the host was accepted and the remaining issue is database privileges.
Error 1130 versus a network connection error
Error 1130 is a server response about the client host. A timeout or “Can’t connect to MySQL server” error happens earlier, before MySQL can return this host-authorization message; see MySQL Error 2003 troubleshooting and check the server address, listening interface, port, firewall, and network route. For connection options, see the MySQL guide to connecting to a server.
For account creation steps, see the MySQL CREATE USER tutorial. For related login failures, see MySQL Error 1045. Browse the MySQL error troubleshooting index for other database and SQL errors.