Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to connect to my database which is hosted on 000webhost. I am connecting from SmartFoxServer, and they allow database connections. All you have to do is change some of the settings in the smartfoxserver xml file.

I have successfully managed to connect to my localhost mysql database using these settings.

 <databaseManager active="true">
    <testSql>SELECT id FROM users LIMIT 1</testSql>

But when I tried to connect to my external database which is hosted on 000webhost and looks like this ...

Using these settings

<testSql>SELECT id FROM users LIMIT 1</testSql>

I get the following error...

Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
Message: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driv
er has not received any packets from the server.
Description: The DBManager Test SQL failed
Please double check your SQL code and make sure that Database server is running.


But when I run php files on my localhost and ask for database connection like this, it works

$db_username = "a5939459_user";
$db_name = "a5939459_data";
$db_password = "censored";
$db_host = "";
mysql_connect($db_host,$db_username, $db_password, $db_name);
mysql_select_db($db_name) or die (mysql_error());
share|improve this question
up vote 0 down vote accepted

It is a big security issue to open up a database/mysql port for external/Internet connections. So when they created your database, they will most likely assign a user to connect only from limited source IPs, mostly Internal IPs. You need to communicate with their support for information from which source IPs you are allowed to connect. As John mentioned, the resolves to a private IP address, and that implies you are most likely allowed to connect to it from some other private IP, which you might connect to through VPN or other means.  14189   IN      A
share|improve this answer
Plz look at the edit – Joe Slater Feb 22 '13 at 15:34
Oh, I can connect through php files because they do not require port but jdbc requires port? Is that the reason? – Joe Slater Feb 22 '13 at 15:50
yes for jdbc you will need the port number - jdbc:mysql:// – Daniel t. Feb 22 '13 at 15:52
I tried with port number but I still get the same error. Do you know solution to this problem? What options do I have from here? – Joe Slater Feb 22 '13 at 15:54

The MySQL host they give you has a 10. IP address, which is unroutable on the Internet. You can only connect to that host from the web host they provide, not from another host.

share|improve this answer
At the moment, my smartfox server is on my laptop, but at the end I am going to upload it to my remote server on amazon ec2. But my mysql database will be on webhost? Will it work? – Joe Slater Feb 22 '13 at 15:26
I do not understand you fully, do you mean I can not access mysql database from anywhere else except from the files that are uploaded on the webhost? – Joe Slater Feb 22 '13 at 15:29
No. Your EC2 instance will not be able to get to the server to talk to the database. Only the 000webhost web server can talk to that database server. – John Feb 22 '13 at 15:29
Plz look at the edit. – Joe Slater Feb 22 '13 at 15:35

As pointed by others, the problem was indeed that 000webhost does not allow remote connections to mysql databases.

Ended up using this for my mysql databases. It is free. It is actually quite reliable and fast. Has free remote connections allowed. Has phpMyAdmin.

Not sure about the security though, but otherwise a great alternative.

share|improve this answer

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.