Windows更新重启后XAMPP无法访问localhost及phpMyAdmin求助
Hey there, let's work through this issue together—Windows updates have a knack for messing with local dev environments, right? Here are the most common fixes to get your XAMPP PHP project back up and running:
1. Verify XAMPP Services Are Running
First things first: fire up your XAMPP Control Panel and double-check that Apache (and MySQL if your project uses it) is showing as "Running". If Apache fails to start, the most likely culprit is a port conflict:
- Click the "Config" button next to Apache, open
httpd.conf, and search forListen 80—change it toListen 8080. - Then open
httpd-ssl.conf(also in the Apache config menu) and changeListen 443toListen 4433. - Save both files, restart Apache, and try accessing your project at
http://localhost:8080instead.
2. Check Windows Firewall Rules
Windows updates often reset firewall permissions, blocking Apache from communicating. Here's how to fix it:
- Open Windows Defender Firewall and click "Allow an app or feature through Windows Defender Firewall".
- Click "Change settings" (you'll need admin rights), then look for entries like "Apache HTTP Server" or
httpd.exe. - Make sure both "Private" and "Public" (at least Private) are checked. If you don't see Apache listed, click "Allow another app", browse to
[your XAMPP folder]/apache/bin/httpd.exe, add it, and enable the permissions.
3. Resolve Port Conflicts
If Apache won't start even after changing ports, a system process might be hogging the default ports. Let's check:
- Open Command Prompt as admin and run:
netstat -ano | findstr ":80" - Look for the PID number in the last column. If the PID is
4, that's the built-in HTTP.sys service. Disable it with these commands:net stop http sc config http start= disabled - Restart your computer, then try starting Apache again. If it's another PID, use Task Manager to find and close the process (like Skype, Teams, or a random background app).
4. Reset Apache Configuration Files
Windows updates can sometimes corrupt XAMPP config files. Try restoring defaults:
- Backup your current
httpd.confandhttpd-vhosts.conf(found inXAMPP/apache/conf/andXAMPP/apache/conf/extra/). - Copy the default versions from the XAMPP installation package (or re-extract them if you still have the installer) and replace your existing files.
- Restart Apache and test your project.
5. Check the Hosts File
Occasionally, updates modify the hosts file, breaking the localhost mapping:
- Open Notepad as admin, then open
C:\Windows\System32\drivers\etc\hosts. - Make sure you have this line at the top:
127.0.0.1 localhost - Save the file, then run
ipconfig /flushdnsin Command Prompt to refresh DNS settings.
Try these steps in order—most of the time, the issue is either a port conflict or a firewall rule reset from the Windows update. Let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者Waruna Dananjaya

