phpMyAdmin:mysqli_real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it

What’s the solution? I’ve searched everywhere. Cannot find an answer. I’m using Windows 10

please post your code

This is likely a firewall issue.

2 Likes

I’m with @benanamen on this. The MySQL server might also be down as well. Make sure it’s running. If it isn’t, investigate why it’s happening. Could be bad data which causes MySQL server to crash.

Post my code? I’ve installed phpMyAdmin and MySQL. I can connect to MySQL using Command Prompt, and all works. But Windows 10 is preventing access from phpMyAdmin. This isn’t a fault with the software or MySQL.It isn’t a coding problem. All worked fine when on Windows XP. I recently bought a new computer and installed Apache 2.4, PHP5.6 and MySQL8.0. Everything works except I cannot access MySQL from phpMyAdmin.

That’s what I’m thinking too, but I disabled firewall and still had the issue. Unless I didn’t really disable it, but only thought I did. Can you give me some instruction on that?

The MySQL server is not down. I can connect with Command Prompt. All is fine. This is a permissions issue: " No connection could be made because the target machine actively refused it" This, this isn’t a coding or software problem. It’s with windows 10. In trying to resolve this issue, I have searched the Web for days, and find MANY people have this same issue, but no solution found as yet, though many have offered various “fixes.” No one thus far has said they have resolved the issue using any of the “fixes” offered.

Are we talking about a remote server or is the DB on your local computer? If it is a remote server, it is the firewall on that computer. I use one and one for a VPS and have to go to their control panel to enable the access.

No, we’re talking about my local machine only. I use it for my development work. I’m the only user. When I had my Windows XP machine in use, I logged in with default ‘root’ and password. All worked. Now I’m just trying to get everything set up on my new computer, with Windows 10, which I’m still trying to get familiar with (only had it a few weeks).

You might be better asking in the server configuration section of the board, rather than this one that deals mainly with PHP programming and related issues. When you ask in here, people presume that it’s doing it from some code only, hence the request to see it.

1 Like

Did you install mysql by itself or part of a LAMP package? Save yourself the hassle and install Laragon. It is better than XAMPP. Laragon will install everything you need for a LAMP stack with no hassles. It just works. It also creates virtual hosts for you automatically and has a mail handler already setup which gives it a leg up on XAMPP.

Well, I looked all over the board to find the appropriate place. I didn’t find anything else.

I installed each program individually …originally on my Windows XP machine some years ago, using Keven Yank’s book, "Build your own database driven web site using PHP and MySQL. It was easy. Now, I have a new machine, and was just re-installing using the latest versions of each.

Uninstall all the components, Mysql, Php, and whatever and then install Laragon. Problem solved.

Installing the binaries takes extra understanding. My original post wasn’t about coding. I have seen and experienced myself that some bad data that are sent to the MySQL folder can actually break or crash the MySQL server. What I am trying to get at is that some where, your data folder has screwed up and there’s actually broken files (bad data) in that folder.

Can you show us what services are running in your Services manager? You can access it through Task Manager and then clicking on Services. At the bottom, it should have a link or something that opens up the full services manager.

It’s always been my understanding that installing the binaries was the way to go, which is what I’ve always done, and I’m quite familiar with the configuration files. This isn’t an Apache config problem. I’ve enabled the appropriate modules to run MySQL, and the MySQL Server is running fine. As I said above, I can access it with a command prompt and log in. ‘Show databases;’ displays the list of databases as it should. This is purely a problem of access by the User Interface program, phpMyAdmin. Perhaps you’re not familiar with it. It is telling me what’s wrong: “phpMyAdmin:mysqli_real_connect()” …the function that connects to the Server …“(HY000/2002): No connection could be made because the target machine actively refused it” This means my machine; i.e., Windows 10, is the culprit. And I am not the only one that has experienced this problem. If you do a search on the above, you will find page after page of people asking how to fix this problem. The reason I posted here at Sitepoint was because I was sure someone here would have heard of or run into this before, and would know the answer, and I wasn’t finding a solution elsewhere. All answers elsewhere (even from Stack Overflow) were similar; i.e., try this, or try that, but no one had a solution. I also tried the various ‘auth_type’ options in “config.inc.php”. Nothing changed. Received the same “no connection” message.
Some have said that Skype is known to interfere. I don’t use Skype, and as far as I know, it isn’t running.

What is Laragon? I should point out that those who have installed the programs using all-in-one apps like WAMP also have reported the problem.

I moved it to Server Config because this is a configuration problem. It doesn’t have anything relating to PHP other than the error. So moving it to Server Config was more appropriate.

I use it every day so I am aware of it.

What anti-virus do you have? It would be nice to know what you have so we can move forward with figuring out your problem.

Doesn’t necessarily have to be Skype. Anything that is using those ports that MySQL is supposed to be using won’t allow MySQL to sniff those ports. In other words, I would probably try uninstalling MySQL and then reinstalling it and use a different port. I remember running into this problem like 3 or so years ago. But I don’t recall what I did to fix it. Just try reinstalling it and choosing a different port that isn’t being used.

It isn’t a server config problem either. If it were, the server wouldn’t be running. It is running, and it is running correctly. It is a problem of access from a program that was designed to be a user interface to make it easier to manage and create data bases using a browser. The configuration of that program is very simple. Two lines of code are enough for basic configuration for a single user managing one database (in my case, at the present time). Same configuration I used on Windows XP, and it worked. But, as many here probably know, Windows 10 has much more built in security features. I can’t even modify my own code without granting myself privileges that in Windows XP were automatic, as Administrator, when I first set up that machine many years ago. It was frustrating at first, but I’m figuring it out.

I tend to believe the message the program is sending me. The log-in isn’t being rejected. My password isn’t being rejected. It says the machine is refusing the connection.It’s that simple. I believe the problem is with Windows 10, because that’s what it’s telling me.(though not specifically, because it doesn’t know what my OS is).

Windows 10 does have “improved” security and I also have experienced some frustration with giving myself permission to run my code with my system.

Anyway, to eliminate the possibility that a busy port might be the problem try running
C:\> netstat
in the CLI to see if anything looks suspect.

1 Like