Error establishing a database connection with XAMPP September 15, 2022 by Tarik Billa Try using 127.0.0.1:3306 instead of using localhost. :3306 is the default port when using PHP7. That should do it.