MySQL & MariaDB error 1130: Host is not allowed to connect to this MySQL server
No account at all matches the host you connect from, so the server refuses before checking the user name or password. Create an account for your host, or connect from an allowed one.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_HOST_NOT_PRIVILEGED | ER_HOST_NOT_PRIVILEGED |
| SQLSTATE | HY000 | HY000 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
The message names the host as the server sees it: Host '10.0.3.7' is not allowed to connect to this MySQL server. The server checked every row in its account list and found no 'user'@'host' whose host part matches your address, for any user. It refuses straight away, without looking at the user name or password.
This differs from 1045: with 1045 some account matched your host, but the user name or password didn’t fit.
Why it happens
- Fresh installs only create accounts for
localhost(and often127.0.0.1/::1), so the first remote connection, from another server or a Docker container, gets 1130. - The account exists for a specific address (
'app'@'10.0.1.%') and the client now connects from another one: a new subnet, a NAT gateway, or a container network. - With name resolution enabled, the server matches the reverse DNS name of your address. If that doesn’t resolve as expected, an account defined by host name won’t match.
- After too many failed connection attempts from one host the server blocks it, which gives a different error (1129) until
FLUSH HOSTS(orTRUNCATE performance_schema.host_cache).
How to fix it
- Check which host the server sees: the message tells you. Then create an account for it:
CREATE USER 'app'@'10.0.3.%' IDENTIFIED BY '…';and grant what it needs. Prefer a subnet pattern over'%'. - Check that the server listens on the network at all (
bind_address), otherwise you get 2003 instead. - From a machine that can log in,
SELECT user, host FROM mysql.user;shows which hosts are allowed.
The test servers used on this site all have a 'root'@'%' account, which matches every host. That’s why 1130 isn’t reproduced here: it needs a server with no wildcard accounts.