0

my config is like this but when I open the page whit my tables appears this error "Could not connect. No connection could be made because the target machine actively refused it"

    <?php
    
    define('DB_SERVER', 'localhost');
    define('DB_USERNAME', 'root');
    define('DB_PASSWORD', '');
    define('DB_NAME', 'consumo_de_combustiveis');
     
    
    $link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
     
    if($link === false){
        die("ERROR: Could not connect. " . mysqli_connect_error());
    }

?>
Rikuc
  • 1
  • look here for example: https://stackoverflow.com/questions/22736396/mysql-no-connection-could-be-made-because-the-target-machine-actively-refused-it – daniel Feb 15 '22 at 23:49
  • That means there's no MySQL server running on your computer. – Barmar Feb 15 '22 at 23:55
  • 1. Make sure that MySQL server is running ; 2. Check whether the port is default port 3306 (otherwise you need to specify the port in mysqli_connect) – Ken Lee Feb 16 '22 at 00:07
  • If you are running linux, easy things to try (that happened to me in the past) Try disabling SELINUX (setenforce 0) Try stopping fail2ban (systemctl stop fail2ban) Check mysql is running or try running a MYSQL query from the command line through SSH. – kissumisha Feb 16 '22 at 00:24

0 Answers0