localhost not connecting to online DB (but online server working)
Posted by: derand (---.bas512.cwt.btireland.net)
Date: October 04, 2018 01:05AM

Initial 13 questions

+-+-+-+-+-+-+-+-+-+-+-+-
Windows 8 64bit
wamp 3.1.3 32bit
Apache 2.4.33.
PHP 5.6.35
MySQL 5.7.21
MariaDB 10.2.14
Wampserver is green
3 active lines (#) in c:\Windows\System32\drivers\etc\hosts
Yes, access to localhost
No error message
Yes phpMyAdmin OK

ERROR MESSAGE =

Connection failed: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.


AV/FIREWALL = AVAST

WAMP installation = c:\wamp

No Virtual hosts.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Query

+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-

When I try to connect localhost to MySql (on an active domain), I receive the above error.

I have used WAMP without any issue for approx 5 months. Initially I used localhost with phpMyAdmin/MySql in WAMP. For the last 4-6 weeks I am now using localhost and MySQL located on an Irish domain (in preparation for launching my site).

Everything has worked OK until the last 24/48 hours. Since then, all attempts from the localhost to connect to MsSQL fail. However, when I FTP the files to my domain the connection is OK and I can connect to and query the DB. I am making no changes to the files.

I have tried the following:-

- Searching form.wampserver.com, Stackoverflow and youtube. There are a number of replies to similar error messages but none that exactly match my problem
- I disabled Avast (antivirus),
- I checked the c:\...host file,
- I do not think that any system changes have been made to my pc,
- I have not installed any new software,
- I've tried 127.0.0.1 instead of localhost,
- I've checked to see if port 3306 is available (I think it is but I'm new to this and cannot be sure I have done this correctly).


Below is a sample of a file I created to test the connection:-
(PS I know mysql is depreciated - but this was written only to test the connection!)
(PPS Obviously I've removed the real name/pw/host, etc)

<?php

$dbname = 'dbname';
$dbuser = 'username';
$dbpass = 'password';
$dbhost = 'dbname';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'"winking smiley;
mysql_select_db($dbname) or die("Could not open the db '$dbname'"winking smiley;
$test_query = "SHOW TABLES FROM $dbname";  
$result = mysql_query($test_query);
$tblCnt = 0;
while($tbl = mysql_fetch_array($result)) {
  $tblCnt++;
  #echo $tbl[0]."<br />\n";
}
if (!$tblCnt) {
  echo "There are no tables<br />\n";
} else {
  echo "There are $tblCnt tables<br />\n";
}

?>

Any attempt to run this file from Localhost generates the above error. But if the file is FTP to a real domain it successfully connects and prints the number of tables in the DB (which is 6). Therefore, there are no mistakes in the url/db/username/pwd....

To confirm...localhost is working (except for this issue), the DB/MySQL hosted online is working fine (as it makes connections with the test connection file and accepts queries, etc), the username/password, etc. are all correct.

Something has happened in the last 24/48 hours to cause this problem

Finally, I have been saving different versions of my website in development. Each of the last 6 versions have worked. Now none of them work. This proves that there is no problem with a change in the files.

Any help would be *Greatly* appreciated...



Edited 1 time(s). Last edit at 10/04/2018 09:57AM by RiggsFolly.

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: RiggsFolly (Moderator)
Date: October 04, 2018 11:51AM

Hi,

Not totally sure what you are trying to tell us here.

Are you trying to connect to a REMOTE MySQL Server from you local PC?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: derand (217.78.8.---)
Date: October 04, 2018 01:08PM

Yes, all attempts to connect with Mysql on remove server (hosted on a live domain) generate the above error.

Simultaneously, attempts to connect with Mysql on remove server from a livewebpage are successful. Therefore the remote server is online and operating correctly.

Attempts to connect with MySQl in wamp operate fine.


I hope this clarifies my issue.

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: RiggsFolly (Moderator)
Date: October 04, 2018 01:20PM

Hi

Are you getting this error by any chance?

Quote

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/config/dbconf.php:8 Stack trace: #0 /var/www/html/login.php(19): require_once() #1 {main} thrown in /var/www/html/config/dbconf.php on line 8

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: derand (217.78.8.---)
Date: October 04, 2018 01:26PM

Thanks for engaging with this problem, really appreciated. The error I'm receiving is:-

Connection failed: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

As I mentioned, it looks like a classic server offline type error. But this is definitely not the case. I created a connectiontest file (as above) and ran it simultaneously in WAMP and from an online server. The WAMP failed (generating a replica error) the online server made a connection and successfully queried the DB.

The WAMP Mysql port is 3306 and I haven't changed any settings....

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: RiggsFolly (Moderator)
Date: October 04, 2018 01:28PM

Did you setup the MySQL Server on the LIVE Server so the the user account you are connecting with is allowed to connect remotely?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: derand (217.78.8.---)
Date: October 04, 2018 01:33PM

Hi, yes the user account is set up on the live server. As outlined, this has been running fine for over a month (e.g. adding data to the LIVE Mysql, searching, etc). It stopped suddenly in the last 48 hrs.

PS Domain provider has suggest checking my IP address has not changed/been blacklisted. This had occurred to me. Last night - to rule out possible IP address issue - I connected via home WIFI and also tethered to mobile phone. Neither worked. I'm going to forward the IP addressed to IP provider to ensure this is not the issue.



Edited 1 time(s). Last edit at 10/04/2018 01:37PM by derand.

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: RiggsFolly (Moderator)
Date: October 04, 2018 01:38PM

Ok so if it was working, you didn't change anything at your local end, then the only possibility is something changed on the live server.

Maybe you would get further by asking your Hosting Co about this.

This kind of problem is almost impossible for us to diagnose and fix remotely! And as WAMPServer is working fine, that rather removes this question from the scope of the problems we support on this site.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: localhost not connecting to online DB (but online server working)
Posted by: derand (217.78.8.---)
Date: October 04, 2018 02:34PM

Hi, I'm coming around to the same conclusion. I had to rule out all possible issues. Thanks for your help.

Options: ReplyQuote


Sorry, only registered users may post in this forum.