Changing the Apache Port in XAMPP

How to Change the Port

Edit the httpd.conf file to change the port Apache listens on.

(1) Locate the file httpd.conf. This file should be found in C:\xampp\apache\conf (or whichever directory you installed XAMPP in – mine is on my D-drive because that is where I installed XAMPP).

(2) Open the file using a text editor or programmer’s editor (I use notepad++). DO NOT use a word processor (like Word) to open the file, it will badly mess it up.

(3a) Locate the line that says Listen 80. It is line #47 in the XAMPP 1.7.3 install.

(3b) Change the port number (80) to a different number (for this tutorial, I changed it to 1234).

(3c) Save the file.

(4) Restart the Apache Server to have the change take effect. Do this by clicking on the Stop button on the XAMPP control panel and then clicking on the Start button. (You could also just reboot the computer, but that is overkill).

Using the New Port

When you connect to the Apache Server, you will have to append the port number to the URL. Previously where you typed localhost, you will now have to type localhost:1234 (or whatever your new port number is):

Note: in Microsoft Internet Explorer 8 (IE8), it is necessary to prepend the prefix http:// beforelocalhost: localhost:1234 will not work, it must be http://localhost:1234.

I did not observe this with Firefox 4.0 – entering localhost:1234 worked just fine (the browser was able to resolve the address as http://localhost:1234).

Second note: this is not a bug in IE8 – as a convenience, browsers automatically try to fixup URLs for you. Technically, you ARE required to type http:// before every URL you type in.