Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have already uploaded some files in the free web host I chose and created a database there using phpMyAdmin v2.11.4

Also, I have Googled first this question before posting this here but I don't understand some rules and I need a clarification.

The exact error I get from viewing my uploaded file(index.php) is this:

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/1130): Host '' is not allowed to connect to this MySQL server in /home/a6400350/public_html/subdomains/index.php on line 7

Domain name of free web host I'm using is www.000webhost.com

And my php code for connecting to host is:


$host = "sql10.000webhost.com"; //or ""
$username = "a6400350xxxxxx";
$password = "••••••••";

$con = mysqli_connect($host, $username, $password);

  • I also check if the server is down here or it's just me
  • There was also no previlege section in phpMyAdmin page as other suggest

Don't I have any permission to connect programmatically to this host as I am just a free user?


I'm also thinking of uploading the whole XAMPP in the server so I could do the things I'm imagining.

Edit 2

Also one more thing, I imported the database by means of .sql file locally through that server, maybe this has something to do about it?

share|improve this question
The error message seems pretty self-explanatory. I guess your database server doesn't allow remote connections. You need to update its mysql config file. –  Barmar May 8 '14 at 8:55
@Barmar It was on another computer, so how could I possibly access that file? –  mr5 May 8 '14 at 9:02
If the question gets closed, the reason why will be shown. –  Barmar May 8 '14 at 10:00
@Barmar Should I wait for it to be closed to know what's my fault? –  mr5 May 8 '14 at 10:01
Yes. Maybe no one agrees with me and it won't get enough votes to be closed. –  Barmar May 8 '14 at 10:04

4 Answers 4

Most hosting companies provide interface, where you can specify (wild-card % is allowed, which means that every host can connect to the database server, or you can specify only given IP addresses) if the remote computers can connect to the MySQL database.

This option should be inside your hosting account's Administration panel (if you have CPanel it is under section Databases->Remote MySQL).

If you do not use CPanel, then consult with your hosting company, but this option is definitely not in PHPMyAdmin.

share|improve this answer
I cannot find Databases->Remote MySQL there, seems nothing there. What's up with this % thing? How can I use it to check if I'm able to use MySQL programmatically? –  mr5 May 8 '14 at 9:20
What type of control panel do you use when log in ? –  bodi0 May 8 '14 at 9:23
I don't know what type is it but, there's a built-in control panel there (A GUI thing) with lots of tools. One of them is this phpMyAdmin and I can access my database there manually. –  mr5 May 8 '14 at 9:28

i see here that your server address for mysql is :

$host = "sql10.000webhost.com"; //or ""

Also here it states that you dont have permissions to connect

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/1130): Host '' is not allowed to connect to this MySQL

Yet the host you are connecting to and host you are connecting from is the same. I would suggest you change your host to

$host = 'localhost'; //$host = "sql10.000webhost.com"; //or ""

And try now. This will ensure you are connecting to localhost - and you will probably get the same IP(localhost). On most sql servers, when user is created its almost always created for local connections - this is probably true for your situation. Therefore when you used the full real host name it tried connecting to it using its own IP and failed. When you explicite write that you want to connect to localhost, loopback connections will be used and it will probably allow your connection.

share|improve this answer
Now I get Access denied for user... after changing the $host value to "localhost" ?? –  mr5 May 8 '14 at 9:04
That means you haven't granted access for a6400350xxxxxx@localhost. –  Barmar May 8 '14 at 9:05
So does it mean that I need to find another free hosting site that would allow me to connect to mysql programmatically? –  mr5 May 8 '14 at 9:06
No, just use localhost. But if you try to connect to theirs database from totally different server (like house computer or something) i dont remember any FREE hosting that allows unknown IPs to connect to theirs database. –  Seti May 8 '14 at 9:20
If I use "localhost" as the value of $host, I get access denied but if I use "sql10.000webhost.com" as a value, I'm not allowed to connect. How do I know if this free web host site is allowing that kind of operation? –  mr5 May 8 '14 at 9:26

Where are you running your script? Locally or on the free hoster you talk about?

If you are running it on the hoster, you may want to try localhost as $host. Alternatively read the documentation of the hoster for the correct access settings. This should work then.

If you are running your script locally, and want to connect to the database of your hoster: Yes, you will most likely not be allowed to do that.
You can run a local MySQL server instead, which has nothing to do with your free hoster. You then again can use localhost for $host, as the MySQL server will run on your local machine then.

share|improve this answer

Host is not allowed to connect to MySQL Error 1130 is a networking error. The server cannot resolve the hostname of the client. Or the host is not allowed to connect to the MySQL server.

There are basically 2 categories of possible reasons:

* The simple one:

In MySQL a user a user is specified using BOTH the user name and the host from where the user may connect. If no user has been created where the host-part (using wildcards or not) mathces the host of the client trying to connect MySQL will return this error.

* Specific for MySQL 5.7:

When upgrading to MySQL 5.7.3 from a previous version this may occur due to changes to the user table introduced in 5.7.3. There is a good blog about this here http://www.chriscalender.com/?p=1392

For more information refer this bit.ly/1mFcStA

share|improve this answer
For your first solution, I guarantee that the user is up and existing and provided the correct login details.For your second solution, I imported the database by means of .sql file w/c is generated by updated version of MySQL and was parsed by this old version of that kind. However, I cannot do what the link you've mentioned did because it's on the other computer. –  mr5 May 9 '14 at 0:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.