MasterPHP.in
Home Blog XAMPP Not Working? Fix Apache & MySQL Crashing Issues (Step-by-Step Guide)
Background
PHP Setup

XAMPP Not Working? Fix Apache & MySQL Crashing Issues (Step-by-Step Guide)

Admin
April 3, 2026
28 views
XAMPP Not Working? Fix Apache & MySQL Crashing Issues (Step-by-Step Guide)

If XAMPP is crashing or refusing to start, you're not alone — this is one of the most common headaches for beginners and developers alike. The good news: most XAMPP problems come down to just a few root causes, and all of them are fixable.

This guide covers every major issue with clear, step-by-step solutions — no fluff.

What You'll Fix in This Guide

  • Apache not starting (port 80 / 443 conflict)
  • MySQL shutting down unexpectedly
  • XAMPP Control Panel not opening
  • Access denied / login errors
  • Antivirus blocking Apache or MySQL

Why Does XAMPP Crash?

XAMPP runs two core services:

Service Purpose Apache : Runs your PHP files and local website MySQL : Manages your local database

If either service fails to start, your entire local development environment goes down. The two most common culprits are:

  1. Port conflicts — another app is already using the port XAMPP needs
  2. Corrupted data files — from an improper shutdown or failed update

Understanding this will help you diagnose problems faster.


Fix 1: Apache Not Starting (Port 80 / 443 Conflict)

What You'll See

You click Start next to Apache — it turns green for a second, then stops.

Why It Happens

Apache needs port 80 (HTTP) and port 443 (HTTPS) to run. If another application is already using these ports, Apache can't start.

Common culprits:

  • Skype (uses port 80 by default)
  • IIS — Windows Internet Information Services
  • VMware or VirtualBox
  • Another web server (WAMP, Laragon, etc.)

Solution A: Change Apache's Port (Recommended)

This is the cleanest fix — it doesn't require uninstalling anything.

Step 1: In the XAMPP Control Panel, click Config next to Apache → select httpd.conf

Step 2: Find this line:

Listen 80

Change it to:

Listen 8080

Step 3: In the same file, find:

ServerName localhost:80

Change it to:

ServerName localhost:8080

Step 4: Save the file, then click Start on Apache.

Step 5: Open your browser and go to:

http://localhost:8080


Solution B: Find and Stop the Conflicting App

To identify what's using port 80:

Open Command Prompt as Administrator and run:

bash

netstat -ano | findstr :80

Note the PID in the last column, then open Task Manager → Details tab and find that PID to see which app it is.

Common fixes:

  • Skype: Go to Settings → Advanced → uncheck "Use port 80 and 443 as alternatives"
  • IIS: Press Win + R, type services.msc, find World Wide Web Publishing Service, right-click → Stop


Fix 2: MySQL Not Starting or Shutting Down Immediately

What You'll See

MySQL starts briefly then shows a red status, or you see errors like MySQL shutdown unexpectedly.

Why It Happens

  • Corrupted database files (most common)
  • Port 3306 is already in use
  • Improper system shutdown while MySQL was running

Solution A: Restore from Backup Folder (Most Effective)

XAMPP ships with a backup of the default MySQL data. Here's how to use it:

Step 1: Navigate to:

C:\xampp\mysql\

Step 2: Rename the existing data folder to data_old

Step 3: Find the backup folder in the same directory and copy it

Step 4: Rename the copy to data

Step 5: Open data_old and copy your custom database folders (the ones you created) into the new data folder

⚠️ Do NOT copy these system folders: mysql, performance_schema, phpmyadmin

Step 6: Restart MySQL from the XAMPP Control Panel.

Solution B: Change MySQL's Port

If port 3306 is taken by another MySQL instance or app:

Step 1: In XAMPP, click Config next to MySQL → open my.ini

Step 2: Find:

port=3306

Change to:

port=3307

Step 3: Save and restart MySQL.

Step 4: Update your PHP connection string to use the new port:

php

$conn = new mysqli("localhost", "root", "", "your_db", 3307);


Fix 3: XAMPP Control Panel Won't Open

Quick Fixes

  1. Run as Administrator — Right-click xampp-control.exeRun as administrator. This is the fix for 80% of cases.
  • Check your installation path — XAMPP must be installed in a simple path: ✅ C:\xampp
  • C:\Program Files\xampp (spaces and permissions cause issues)
  1. Reinstall if necessary — If configs are fully broken, a clean reinstall into C:\xampp is often faster than diagnosing a deeply broken setup.


Fix 4: Access Denied or MySQL Login Error

Symptoms

  • phpMyAdmin shows "Access denied for user 'root'"
  • Your PHP app can't connect to the database

Fix

XAMPP's default MySQL credentials are:

FieldValueHostlocalhostUsernamerootPassword(leave blank)

If you've set a custom root password and forgotten it, you'll need to reset it via the command line:

bash

C:\xampp\mysql\bin\mysql.exe -u root

Then run:

sql

ALTER USER 'root'@'localhost' IDENTIFIED BY '';
FLUSH PRIVILEGES;


Fix 5: Antivirus Blocking Apache or MySQL

Windows Defender and third-party antivirus tools sometimes flag XAMPP as a threat because it opens network ports locally.

How to Fix

Option A — Add an exception (Recommended): Add the entire XAMPP folder to your antivirus's exclusion list:

C:\xampp\

Option B — Temporarily disable: Turn off real-time protection, start Apache/MySQL, then re-enable. This confirms whether antivirus is the issue.

On Windows Defender, go to: Windows Security → Virus & threat protection → Manage settings → Add or remove exclusions


Pro Tips Most Tutorials Skip

These small habits prevent 90% of XAMPP problems:

  • Always stop XAMPP before shutting down your PC. Abrupt shutdowns corrupt MySQL's data files — this is the #1 cause of MySQL crashes.
  • Never run XAMPP alongside WAMP or Laragon on the same ports.
  • Keep all your projects inside C:\xampp\htdocs\ — this is Apache's web root.
  • Back up your data folder regularly, especially before updating XAMPP.
  • Check the XAMPP error logs before googling — they tell you exactly what failed: Apache logs: C:\xampp\apache\logs\error.log
  • MySQL logs: C:\xampp\mysql\data\mysql_error.log


When Should You Reinstall XAMPP?

Reinstalling is a last resort. Only do it if:

  • Multiple services are broken and configs are corrupted beyond repair
  • You're getting errors even after a fresh install of Windows

In all other cases, the fixes above are faster and safer than reinstalling.


Quick Reference: XAMPP Fix Cheat Sheet

Problem Most Likely Cause Fastest Fix Apache won't start Port 80 conflict Change Apache to port 8080 MySQL crashes Corrupted data files Restore from backup folder Control Panel won't open Permissions issue Run as Administrator Access denied (MySQL)Wrong credentials Use root with blank password Services blocked Antivirus interference Add XAMPP to exceptions.

Share this article: