Menu
User

DropVPS Team

Writer: John hens

How to Change Apache Default Port in XAMPP

How to Change Apache Default Port in XAMPP

Publication Date

12/24/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Changing the Apache default port in XAMPP is useful when port 80 or 443 is already in use by another application such as Skype, IIS, or Docker.

STEP 1: Stop Apache in XAMPP

Before changing the Apache default port, you must stop the Apache service to avoid configuration conflicts and ensure the new port settings are applied correctly.

sudo /opt/lampp/lampp stopapache

STEP 2: Open Apache Configuration File (httpd.conf)

Open the httpd.conf file using a text editor such as Notepad++ or VS Code with administrator privileges, then locate the Listen and ServerName directives for editing in the next step.

# Windows (XAMPP default path)
C:\xampp\apache\conf\httpd.conf

STEP 3: Change the Listen Port

In this step, you will modify Apache’s main configuration to change the default listening port (usually 80) to a new one, which helps avoid port conflicts and allows XAMPP to run smoothly alongside other services on your system.

Listen 80

Change it to another port, for example 8080:

Listen 8080

STEP 4: Update ServerName Port

After changing the Apache Listen port, you also need to update the ServerName directive so Apache knows which port it should respond on.

ServerName localhost:80

Update it to match the new port:

ServerName localhost:8080

STEP 5: Update Virtual Hosts (Important)

After changing Apache’s main listening port, it’s essential to update the Virtual Hosts configuration so your websites continue to load correctly without conflicts.

apache/conf/extra/httpd-vhosts.conf

Change:

<VirtualHost *:80>
<VirtualHost *:8080>

STEP 6: Restart Apache in XAMPP

After updating the Apache configuration files and changing the default port, you must restart Apache so the new settings take effect and the web server can bind to the updated port correctly.

cd C:\xampp\apache\bin
httpd.exe -k restart

opening your browser and visiting:

http://localhost:NEW_PORT

STEP 7: Access Apache Using the New Port

After changing and restarting Apache with the new port, the final step is to confirm everything works correctly by accessing your Apache server through a web browser using the updated port number, ensuring the configuration was applied successfully.

http://localhost:8080

STEP 8: Allow the New Port in Firewall (If Needed)

If your system firewall is enabled, you must allow the new Apache port to ensure external access works correctly and prevent connection issues after changing the default port.

Allow inbound TCP port 8080

Linux (UFW):

sudo ufw allow 8080/tcp
sudo ufw reload

STEP 9: Common Errors and Fixes

In this step, you’ll review the most common issues that can occur after changing the Apache default port in XAMPP and learn simple, practical solutions to quickly fix them and ensure Apache runs smoothly without conflicts.

netstat -ano | findstr 8080

Permission denied:

Run XAMPP as Administrator (Windows)

Use sudo on Linux/macOS
Windows VPS
U
Loading...

Related Posts