Warning: mysqli::__construct(): (HY000/1130): Host is not allowed to connect to this MariaDB server

Warning: mysqli::__construct(): (HY000/1130): Host is not allowed to connect to this MariaDB server

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Decoding MySQL Error HY000/1130: Host Not Allowed to Connect

When debugging database connectivity issues, you often encounter errors that feel like dead ends until you understand the underlying access control mechanism. The error Warning: mysqli::__construct(): (HY000/1130): Host '...' is not allowed to connect to this MariaDB server is a classic example of such a roadblock. It indicates that while your database user credentials are correct, the specific combination of username and client IP address is blocked by the server's user privilege table.

This restriction is enforced at the protocol level within MariaDB (and MySQL). When you create a user, especially via control panels like cPanel, the system often assigns privileges based on a broad hostname mask, such as % or a specific subnet. However, if your application attempts to connect from an IP address that does not match any of the allowed patterns in the mysql.user table, the connection is rejected immediately upon attempting to open the socket or TCP stream.

To resolve this, you must inspect the current user privileges. You can do this by logging into the server via SSH and accessing the MySQL/MariaDB shell:

mysql -u root -p
SHOW GRANTS FOR 'theveis1_nand1'@'%';

The output of this command reveals the exact host patterns associated with the user. If you see Host '%', it implies the user allows connections from anywhere, which should work regardless of the IP. However, if the host is restricted to a specific subnet or a literal IP that your application server doesn't match, you need to adjust the grant.

If the user was created through cPanel with "all permissions," there is often a discrepancy between what the panel thinks it configured and what the raw database sees. Sometimes, panels create users with Host 'localhost' by default even if they intend for remote access, or they fail to update the host mask correctly after permission changes.

The fix involves granting explicit privileges for the client IP. You have two primary approaches depending on your security posture:

  1. Broad Access: Allow the user to connect from any host (%). This is simple but less secure if the password is compromised, as an attacker could connect from anywhere.

    GRANT ALL PRIVILEGES ON *.* TO 'theveis1_nand1'@'%';
    FLUSH PRIVILEGES;
    
  2. Specific IP Access: Restrict access to a specific subnet or the exact IP of your application server. This is preferred in production environments. First, identify your server's external IP:

    curl ifconfig.me
    

    Then, update the user grants:

    GRANT ALL PRIVILEGES ON `theveis1_userdata`.* TO 'theveis1_nand1'@'your_server_ip';
    FLUSH PRIVILEGES;
    

It is crucial to note that FLUSH PRIVILEGES is required if you are modifying existing grants without dropping and recreating the user. If you used a control panel, ensure you run "Update MySQL/MariaDB Users" within the panel interface afterward, as these tools often cache their own user tables separately from the system database until triggered.

Additionally, check your PHP configuration. The error message in your provided code snippet shows mysqli::__construct failing during initialization. This means the handshake never completes. Ensure that $servername in your connection string is indeed the host IP or domain name you intend to use, and not a local socket path if you are trying to connect remotely. If you are running on a different server than the database, ensure port 3306 (or whatever port MariaDB is listening on) is open in your firewall.

Finally, verify that the mysql.user table reflects these changes immediately. Sometimes, replication delays or caching issues can cause old grant tables to persist briefly after an update. If the error persists after flushing privileges and verifying the IP, consider checking for typos in the username or hostname masks, as case sensitivity is rarely an issue but character encoding (like Cyrillic vs. Latin) in hostnames can sometimes lead to unexpected mismatches if not handled strictly by the database engine.

Our network