MySQL cannot resolve the client IP to a hostname, so it blocks the connection and returns ER_BAD_HOST_ERROR (Can't get hostname for your address).
MySQL Error 1042: ER_BAD_HOST_ERROR occurs when the server fails to resolve the connecting client’s IP address to a hostname. Fix it by disabling reverse DNS lookups (skip-name-resolve) or adding correct host entries in DNS or /etc/hosts.
Can't get hostname for your address
MySQL returns the message "Can't get hostname for your address" with SQLSTATE 08S01 when it cannot convert the connecting client’s IP address into a hostname. This lookup is part of MySQL's host-based authentication process.<\/p>
The failure stops the handshake and the server sends error 1042 back to the client.
No SQL reaches the server because the TCP connection is closed during authentication.<\/p>
MySQL stores privileges in the user table as user@host. When you connect with an IP, the server tries a reverse DNS lookup to build the host string.
If that lookup fails, MySQL sees the host as unknown and produces ER_BAD_HOST_ERROR.<\/p>
Blocking unresolved clients prevents spoofing but also locks out legitimate users behind firewalls, VPNs, or poorly configured DNS. Fixing the underlying lookup keeps connections secure and reliable.<\/p>.
Disabling them with skip-name-resolve eliminates the need for DNS.<\/p>