Error 1130 means your connection reached MySQL, and the server then found no account that allows your client address. This differs from a wrong password: MySQL never got to checking one, because no user@host row matches.
ERROR 1130 (HY000): Host '203.0.113.7' is not allowed to connect to this MySQL server
MariaDB uses the same text. The host in the quotes is the address (or hostname) the server saw. That is the value you must permit, and it may not be the address you expected.
Step 1: confirm what address the server sees
Your laptop, container or app server may connect through NAT, a VPN, Docker's bridge network or a cloud gateway. Run the What Is My IP tool from the machine that opens the connection, and compare it with the address in the error message. If they differ, trust the error message.
If the host looks like a private Docker address (172.x.x.x), your client is connecting from a container network rather than your public IP.
Step 2: create or adjust the account
Log in locally on the database server as an administrator and see what exists:
SELECT user, host FROM mysql.user WHERE user = 'app';
If your client address is not covered, add it:
CREATE USER 'app'@'203.0.113.7' IDENTIFIED BY 'a-strong-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'app'@'203.0.113.7';
A subnet works with a wildcard or netmask, for example 'app'@'10.0.%' or 'app'@'10.0.0.0/255.255.0.0'. Using 'app'@'%' accepts any host, which is convenient and risky; combine it with a firewall that restricts who can reach port 3306.
Note that '%' does not match connections over the Unix socket, which are treated as localhost. You may need both 'app'@'localhost' and 'app'@'%'.
Step 3: reverse DNS can confuse matching
If the server resolves client addresses to hostnames, accounts are matched against the hostname. A stale PTR record or a mismatch makes 'app'@'10.0.1.5' fail when the server sees web1.example.net. Turn lookups off with:
[mysqld]
skip-name-resolve
After that, accounts must use IP addresses (except localhost), so update them first. Restart is required. This also speeds up connections.
Step 4: make sure the network path is open
Error 1130 proves some path works, so do this check mainly if you are unsure, or are about to switch to an account that works. Otherwise you will see connection timeouts or error 2002 instead. For remote access, MySQL must listen on a non-loopback address:
[mysqld]
bind-address = 0.0.0.0
Use a specific interface address if you can. MySQL 8.0 also supports a list of addresses in newer releases. Restart after changing it. Then confirm it is listening:
ss -ltnp | grep 3306
And test from the client side with the पोर्ट चेकर or nc -vz db.example.com 3306. Open the firewall only to the hosts that need it:
sudo ufw allow from 203.0.113.7 to any port 3306 proto tcp
Cloud providers have their own firewall layers (security groups, authorized networks). Check there too.
Step 5: managed databases
On hosted MySQL, the console may control access instead of SQL. Look for authorized networks or an IP allowlist, and for the "allowed host" field when creating the user. Providers like RDS normally create users with '%' and use security groups for network control. Check your provider's documentation for specifics.
Step 6: Docker and local development
- Container to host database: use the host's address (
host.docker.internalon Docker Desktop) and create the user for the Docker bridge range, or'%'. - Container to container: use the compose service name and let the official image create the user with
MYSQL_USERandMYSQL_PASSWORD, which creates it with'%'host. MYSQL_ROOT_HOSTcontrols where root may connect from in the official image; by default root is allowed from any host (%) in many tags, but check the image documentation.
अगले कदम
- If you now get a login failure, read MySQL error 1045.
- If the connection cannot be made, see MySQL error 2002.
- Test the port with the पोर्ट चेकर and check where an address is with the IP लुकअप.
- Verify the DB host's name with the DNS चेकर.
सामान्य प्रश्न
Does error 1130 mean the password is wrong?
No. The server rejected the client before it checked a password because no account permits that host.
Why does localhost work but my server IP does not?
Accounts are bound to hosts. The 'app'@'localhost' account does not apply to remote connections, so create one for the remote address.
Is it safe to use '%' as the host?
It is safe only if the network blocks all but trusted clients. Prefer specific addresses or a private subnet.
Do I need FLUSH PRIVILEGES after creating the user?
No. CREATE USER and GRANT take effect immediately.
Get notified when this fix updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.