Connection refused. MySQL database connection is refused

my php Script:

<?php $servername = "localhost"; $username = "xxxxxxxxx"; $password = "xxxxxxxxxx"; // Create connection with Server $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Server Connection failed: ". $conn->connect_error. "
"); } echo " Server Connected successfully". "
"; ?>

everything was fine for many days and today i try to run upper script and get error: "Server Connection failed: Connection refused:

I created new Database and run script for new Db but error is again appeared again for new Db. Please help what coudl be wrong?

2 Likes

I’m having the same issue. please let me know if you resolve it. thanx

so far i haven’t got support or feedback from this.
and i’ve tried multiple hosts like


127.0.0.1
etc
but neither of them works.

I’m facing the same problem too. Although if I go to the site from another internet connection it’s working. But i still can’t access from the existing connection which was working fine for me before.

P.S. Check if you have closed your database connections properly.

@sumanmitra97

i noticed that i can acess server when i use internet connection where i first run my scrip. Any other (i tested 3) give ‘Connection refused’ error. Wierd to me…how can it be so strange? Before crushed it was running everywhere i mean it was tested in a lot of places (diffrent Wi-fi connections).

I’m having a similar issue. I’ve created a simple test PHP script that attempts to connect to the DB and returns a success message if it succeeds and a error code + message if it doesn’t. If I access the script from one device it succeeds, if I access the same script from another device I get a 2002 (Connection refused) error. Had no issues up until a few days ago. Please let me know if you find a resolution to this issue.

Me too. new user for 000webhost.
i have same problem as TS.

Please, anyone help us. onegai~

I advise you take away the variables and enter in the data straight into your function. This always works for me!