ERROR SQLSTATE HY000 2002 No connection could be made because the target machine actively refused it

0 votes

I was debugging my code when a surprising error happened. There are a number of issues with the connection to the database.

ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.
( ! ) Fatal error: Uncaught exception 'PDOException' with message ' in C:\wamp\www\web\main\users.php on line 15
( ! ) PDOException: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. in C:\wamp\www\web\main\users.php on line 15

This is the code of where the error is pointing

function __construct()
        {
            $this->con = new PDO("mysql:host=".$this->host.";dbname=".$this->db,$this->user,$this->pass);
        }

Since I don't frequently experience issues like this, I haven't done any research on WAMP, thus I'm not sure what to do. I appreciate you helping me.

Sep 12, 2022 in Database by Kithuzzz
• 38,000 points
13,071 views

1 answer to this question.

0 votes

One of the services has not begun if the WAMP symbol is orange. Since you are receiving the notice that there is no server operating and thus listening for requests in your situation, it appears that MySQL has not started.

Check the MySQL log first, and if that doesn't reveal anything, check the Windows event log under Windows -> Applications. There are error messages that can help you figure out why MySQL won't start.

Sometimes this is brought on by WAMPServers MySQL picking up a my.ini file from another install, typically in the windows or windows system32 folders. Search for "my.ini" and "my.cnf" and, if you come across either of these files outside of the wamp folder hierarchy, delete or at the very least rename them so they can no longer be found. Restart the MySQL service after that.

I hope this helps you.

Get a further understanding from the SQL Certification Course

answered Sep 13, 2022 by narikkadan
• 63,600 points

Related Questions In Database

0 votes
1 answer

What are the different authentication modes in SQL Server? How can it be changed?

Windows mode and Mixed Mode – SQL ...READ MORE

answered Oct 29, 2018 in Database by Sahiti
• 6,370 points
1,212 views
0 votes
3 answers

MySQL "Could not create connection to database serve" error

Pls check that you have MySQL server ...READ MORE

answered Jul 3, 2020 in Database by anonymous
29,904 views
0 votes
0 answers
0 votes
0 answers

PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused

I am trying to connect MySQL Database ...READ MORE

Jun 24, 2022 in PHP by narikkadan
• 63,600 points
3,383 views
0 votes
0 answers

PDOException SQLSTATE[HY000] [2002] No such file or directory

My (very basic) site appears to have ...READ MORE

Sep 3, 2022 in Database by Kithuzzz
• 38,000 points
2,052 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,543 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,250 points
1,272 views
0 votes
1 answer

Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) in sql 2008

Solution Go to Start > Programs > Microsoft SQL Server > Enterprise Manager. Right-click the SQL ...READ MORE

answered Sep 12, 2022 in Database by narikkadan
• 63,600 points
1,094 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP