Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

localhost not connecting to online DB (but online server working) (no replies)

$
0
0
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'");
mysql_select_db($dbname) or die("Could not open the db '$dbname'");
$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...

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>