How to: Change Your Apache Listen Port Number in XAMPP

Recently my XAMPP install in Windows 10 started showing an Apache error “Apache WILL NOT start without the configured ports free!”. In my case another service is now using port 80 (happens to be a Microsoft service) which is the default port for Apache which is causing this error.

In this how to we’ll cover changing your Apache listen port from port 80 to fix that problem.

  1. Open the XAMPP control panel, stop all running modules.
  2. Click the “Config” button for the Apache module and select “Apache (httpd.conf)”.
  3. Alternately you can open the file located in your XAMPP install folder “/apache/conf/httpd.conf” with a different text editor.
  4. Find the following line around line 58 in the file. Port 80 is the default listen port for Apache.
    Listen 80
  5. Change it to another port number not in use, for this example we’ll change it to port 8080.
    Listen 8080
  6. Find the following line around line 225 in the same file. The ServerName variable is used to give the server a name and port to identify itself with.
    ServerName localhost:80
  7. Replace it with the same port number you used in step 4.
    ServerName localhost:8080
  8. Save the conf file and in the XAMPP control panel click “Config” and “Service and Port Settings”. Change the “Main Port” under the Apache tab to the port set in step 4.
  9. At this point you shouldn’t see any port errors and can start the Apache module again.
  10. Open your browser and navigate to “localhost:8080” where you should now see the XAMPP dashboard or click on “Admin” in the XAMPP control panel.

Bonus:

If you need to change the ports for a https connection change the same settings in the “httpd-ssl.conf” file.