// MySQL error reference

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
Error message
Host '%s' is not allowed to connect to this MySQL server

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_resolve is off).

How to fix it

  1. On the server, see which hosts the user can connect from.

    SELECT user, host FROM mysql.user WHERE user = 'app';
  2. Create an account for the client's host or network and grant it what it needs. Avoid opening root to %.

    CREATE USER 'app'@'192.168.1.%' IDENTIFIED BY 'strong-password';
    GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'app'@'192.168.1.%';
  3. If you can't reach the server at all from the remote host afterwards, check bind_address and the firewall (see error 2003).

Related errors

More access and privileges errors

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.

// fewer errors, faster fixes

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.