How to Fix ERROR 1130 (HY000) Host is not allowed to connect to this MySQL server?

ERROR 1130 (HY000) is a common MySQL connection error that displays "Host 'host_name' is not allowed to connect to this MySQL server." This error occurs when a client attempts to connect to a MySQL server but lacks proper authorization. Understanding and resolving this error is crucial for database administrators and developers working with remote MySQL connections.

Understanding the Error

ERROR 1130 (HY000) indicates that the MySQL server has rejected a connection attempt from a specific host or IP address. This security feature prevents unauthorized access to the database server by restricting connections to only approved hosts.

Common Causes

  • User account restrictions The MySQL user account is configured to allow connections only from specific hosts (e.g., localhost)

  • Firewall blocking Network firewalls preventing traffic on MySQL port 3306

  • bind-address configuration MySQL server configured to accept connections only from localhost

  • Incorrect credentials Using wrong username, password, or host specification

Fixing the Error

Method 1: Grant User Privileges for Remote Access

Connect to MySQL as root user and check existing user privileges

SHOW GRANTS FOR 'username'@'localhost';

To allow connections from any host, create a new user or modify existing user

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

For specific IP address access

GRANT ALL PRIVILEGES ON *.* TO 'username'@'192.168.1.100' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Method 2: Configure MySQL Bind Address

Edit the MySQL configuration file to allow remote connections

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Locate and modify the bind-address setting

# Comment out or change this line:
# bind-address = 127.0.0.1

# To allow all connections:
bind-address = 0.0.0.0

# Or specify your server's IP:
bind-address = 192.168.1.10

Method 3: Configure Firewall Settings

Allow MySQL traffic through the firewall. For Ubuntu/Debian

sudo ufw allow 3306/tcp
sudo ufw reload

For CentOS/RHEL

sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --reload

Method 4: Restart MySQL Service

After making configuration changes, restart MySQL to apply settings

Linux Systems:

sudo systemctl restart mysql
# or
sudo service mysql restart

Windows Systems:

net stop mysql
net start mysql

Verification Steps

Test the connection from the remote host

mysql -h server_ip_address -u username -p

Check if MySQL is listening on all interfaces

netstat -an | grep :3306

Security Best Practices

  • Limit host access Grant access only to specific IP addresses instead of using '%' wildcard

  • Use strong passwords Implement complex passwords for database users

  • Regular updates Keep MySQL server updated with latest security patches

  • Monitor connections Review MySQL logs regularly for unauthorized access attempts

  • SSL encryption Enable SSL for remote connections to encrypt data in transit

Conclusion

ERROR 1130 (HY000) is resolved by properly configuring user privileges, MySQL bind address settings, and firewall rules. The key is granting appropriate host access while maintaining security by limiting connections to trusted IP addresses and implementing strong authentication practices.

Updated on: 2026-03-17T09:01:38+05:30

17K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements