MySQL error 1130: Host is not allowed to connect
No account exists for the host you're connecting from, so the server refuses the connection before checking any password.
- Error number
1130- Name
ER_HOST_NOT_PRIVILEGED- SQLSTATE
HY000- Category
- Access and privileges
What it means
MySQL matches every connection to an account by user name and client host. If no account at all covers the client's host, the server answers with 1130 straight away. It's common right after installing MySQL, where root exists only as 'root'@'localhost'.
Common causes
- Connecting remotely when accounts exist only for
localhost. - Connecting from a Docker container or another machine whose address the account's host pattern doesn't cover.
- The server resolves your IP to a host name that doesn't match the account (when
skip_name_resolveis off).
How to fix it
-
On the server, see which hosts the user can connect from.
SELECT user, host FROM mysql.user WHERE user = 'app';
-
Create an account for the client's host or network and grant it what it needs. Avoid opening
rootto%.CREATE USER 'app'@'192.168.1.%' IDENTIFIED BY 'strong-password'; GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'app'@'192.168.1.%';
-
If you can't reach the server at all from the remote host afterwards, check
bind_addressand the firewall (see error 2003).
Related errors
1045Access denied for user2003Can't connect to MySQL server on host1044Access denied for user to database
More access and privileges errors
1698Access denied for user (no password)1142Command denied to user for table1143Command denied to user for column1227Access denied; you need a privilege1396Operation CREATE USER failed1419SUPER privilege needed with binary logging1449Definer user does not exist
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.