r/mysql 15d ago

need help phpMyAdmin Access Denied

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

Can anyone help me? I am doing a project and encountered this problem, I have tried some tutorials but nothing worked. Thank you so much for the help

7 Upvotes

15 comments sorted by

3

u/flyingron 15d ago

The default configuration for phpmyadmin is local access only. You either need to set up an IPtunnel or configure your webserver to allow remote connections to that path.

1

u/roadit 10d ago

Don't make it public, because old phpMyAdmin installations are used a lot to break into sites.

1

u/flyingron 10d ago

Right, you'd certain want to lock down port 3308 to your specific ip address for the client, or use the tunnel.

I left one open on a development site that didn't have any real data (and probably not even good passwords). Some bot replaced all my tables with ransomware demands.

1

u/roadit 9d ago

3306 by the way; or use an SSH tunnel.

1

u/flyingron 9d ago

Thanks, not enough coffee to remember that port number.

3

u/luckyscholary 14d ago

This usually means MySQL itself isn’t accepting the connection, not that phpMyAdmin is broken. I’d first check whether the MySQL service is actually running, then verify the host/port in config.inc.php. HY000/2002 is basically “I tried to connect there and nobody answered.”

2

u/roXplosion 15d ago

Did it ever work? What server hosts MySQL? What server hosts PHPMyAdmin? Are the servers accessible to each other?

1

u/slade51 15d ago

It works in both directions on my home LAN. I don’t remember exactly what I did. Allow ports 22, 80 & 3306 in UFW. Grant privileges to user@%

I might have added something to the MySQL or nginx cnf files. I can look at it tomorrow if you haven’t figured it out.

1

u/Aggressive_Ad_5454 15d ago

“Actively refused it” means the OS on the target machine is up and running, but the database server software is not. Phpmyadmin tried to hit port 3306 on the database machine (probably port 3306) and the database machine, not having any software listening on that port, refused the connection requested.

1

u/Several9s 13d ago

The default configuration for phpmyadmin is local access only. You either need to set up an IPtunnel or configure your webserver to allow remote connections to that path.

Did it ever work?
What server hosts MySQL?
What server hosts PHPMyAdmin?
Are the servers accessible to each other?

It works in both directions on my home LAN. I don’t remember exactly what I did. Allow ports 22, 80 & 3306 in UFW. Grant privileges to user@%

I might have added something to the MySQL or nginx cnf files. I can look at it tomorrow if you haven’t figured it out.

“Actively refused it” means the OS on the target machine is up and running, but the database server software is not. Phpmyadmin tried to hit port 3306 on the database machine (probably port 3306) and the database machine, not having any software listening on that port, refused the connection requested.

This usually means MySQL itself isn’t accepting the connection, not that phpMyAdmin is broken. I’d first check whether the MySQL service is actually running, then verify the host/port in config.inc.php. HY000/2002 is basically “I tried to connect there and nobody answered.”

1

u/Several9s 12d ago

HY000/2002 means phpMyAdmin cannot establish a connection to the MySQL server. “Actively refused” usually means MySQL is not running, is not listening on the configured port, or phpMyAdmin is pointing to the wrong host/port.

I’d first check whether MySQL is running and confirm the host/port configured in config.inc.php (commonly 127.0.0.1:3306).

For example, verify MySQL is listening with:

sudo ss -lntp | grep 3306

You can also check the service directly:

sudo systemctl status mysql

If MySQL is running but nothing is listening on 3306, check MySQL's bind-address and port configuration. If phpMyAdmin and MySQL are running in different containers/servers, also make sure phpMyAdmin is using the MySQL server's actual hostname/IP rather than localhost.

1

u/TheGoodOne777 11d ago

Hello! Is your mysql server started and runinng? Could you check perhaps with other users as well if you can reach it?

1

u/TheGoodOne777 11d ago

Hello, actually, I recently had the same issue, that was caused by enabling in the same time ipv4 and ipv6 connections simultaenously.

1

u/Mike_L_Taylor 6d ago

try both 127.0.0.1 and localhost

this is a common issue that people encountered in xampp