Home / Articles / Fixing XAMPP Connection Problems

Fixing XAMPP Connection Problems

Posted 7 hours ago in Web Development · 2 reads

Fixing XAMPP Connection Problems
XAMPP is one of the most popular tools for running PHP and MySQL locally, but it's also notorious for a handful of recurring connection problems — especially on Windows. Here's how to work through them in order, starting with the most common causes.

1. "This site can't be reached" when opening localhost
First, check that both Apache and MySQL show a green "Running" status in the XAMPP Control Panel. If Apache won't even start, click the "Logs" button next to it — the error log almost always tells you exactly what's wrong, usually a port conflict (see #2 below).

2. Apache won't start — port 80 or 443 already in use
This is the single most common XAMPP issue. Another program on your computer — often Skype, IIS, VMware, or even Windows' own World Wide Web Publishing Service — is already using port 80. Two ways to fix it:
- Close the conflicting program, or
- Change Apache's port in XAMPP: open the Config for Apache (httpd.conf), find "Listen 80" and change it to something like "Listen 8080", then access your site at localhost:8080 instead.

3. MySQL won't start — port 3306 conflict
Same idea as above, but for MySQL's port. This often happens if you have another MySQL server (or a previous XAMPP install) still running in the background. Open Task Manager, end any existing mysqld.exe processes, then try starting MySQL again from the Control Panel.

4. "Access denied for user 'root'@'localhost'"
This means your PHP code's database credentials don't match what MySQL actually expects. By default, XAMPP's MySQL root user has no password. Double check your connection code uses:
- Username: root
- Password: (blank/empty)
- Host: localhost
If you previously set a root password and forgot it, you can reset it through phpMyAdmin's User Accounts tab, or reinstall XAMPP's MySQL data folder as a last resort.

5. "Unknown database" error
This simply means the database hasn't been created yet, or its name doesn't match what your code expects. Open phpMyAdmin (localhost/phpmyadmin), check the exact database name in the left sidebar, and make sure it matches your config file exactly — database names in MySQL are case-sensitive.

6. phpMyAdmin itself won't load or shows a connection error
This is almost always because MySQL isn't actually running (see #3), or because phpMyAdmin's own config file is pointing to the wrong port after you changed MySQL's default port. Check config.inc.php in the phpMyAdmin folder if you've customized any ports.

7. Changes to your PHP files aren't showing up
Make sure you're editing files inside XAMPP's htdocs folder, not a copy somewhere else — this is a very common mix-up, especially if you have multiple project folders. Also try a hard refresh (Ctrl+F5) to rule out your browser simply caching an old version of the page.

8. Firewall or antivirus blocking connections
Occasionally, Windows Firewall or antivirus software blocks Apache or MySQL from binding to their ports. If everything above checks out and it's still failing, try temporarily disabling your firewall to confirm whether that's the cause, then add a proper exception instead of leaving it off.

Most XAMPP problems come down to a port conflict or a mismatch between what your code expects and what's actually running. Working through these checks in order will resolve the vast majority of cases without needing to reinstall anything.
Back to Articles