Port Forwarding
Revised 9-14-2009
* Added a video tutorial and re-wrote it using a Linksys WRT54G router.
Revised 2-20-2009
* I noticed the article didn't mention how to properly change Apache's settings for using a different port, so I added that info here.
How To Configure Port Forwarding To Make Your Server Publicly Accessible.
If you're trying to publish your Apache/XAMPP server to the outside world and are connected through a router, then you will need to know how to do the following. If done properly, you will be able to connect to your server via your external IP address after completing this tutorial.
Now this process will very slightly depending on who the manufacturer of your router is and what version firmware it's running, but the following should be close enough for you to follow along.
In this tutorial, I demonstrate how to set it up in a Linksys WRT54G router, which is a pretty common wireless router nowadays.
I'm assuming you've already setup and configured your web server software and can connect to it locally via http://127.0.0.1 and http://localhost. If you haven't already done this, I suggest you do so now, as proceeding on will not help you much.
You also need to obtain your router's configuration IP address, which you can find in the router's manual. If you don't have the manual, check the manufacturer's website for an online copy or google the information for your router model. You also need the login info for it too.
Here's a few common default ones:
| Manufacturer/Model | Configuration IP |
| Linksys/WRT54G - WRT54GS | 192.168.1.1 |
| 2WIRE | 192.168.1.254 |
If you're trying to find out how to forward port 80 to another port (example, your ISP blocks port 80), then read this.
VIDEO TUTORIAL
WRITTEN TUTORIAL
Now let's begin.
1.) Log into your router's configuration menu using your web browser.
The one shown here is the most common address, especially for Linksys Routers. Check your router's manual to determine the correct address for your router.
![]()
2.) You will come to a screen similar to this but will vary depending on your router's manufacturer and the firmware version.

3.) Now click on the Status tab on the far top right and then click on Local Network.
You should see something similar to this, then click on the DHCP Clients Table.

4.) You should see a screen similar to this one.
Look for your computer's name and then write down the Local IP address for it.
You can close this screen once you're finished.
In this tutorial, my PC name is JuJus-PC and my local IP is 192.168.1.105.

5.) Open your browser and then enter the Local IP address for your computer.
![]()
If your Apache/XAMPP server is running and you were able to access it via 127.0.0.1, you should see your website now via
your computer's local IP. If not, verify you have the correct IP for your server.
Sometimes I've seen my PC be one of the IP's that do not have a name beside them, so try these also if you've verified the
IP for your computer's name and the IP beside it doesn't work.
6.) Now find the "Port Forwarding" section in your router menu. You may have to search around to find it.
In the Linksys routers, you can find it by clicking on the Applications & Gaming tab and then
Port Range Forward.
* Below shows me forwarding port 80 for Apache, 433 for https, and port 21 for my FTP Server. *

Now enter a name (it doesn't matter what it is, just name it something you can identify it by).
Next, set the port(s). 80 is the port for most of your web page traffic access including forums, blogs, etc. Port 21 is the default port for FTP access. If you're using features requiring additional ports such as https, pop3, etc., then you will need to also enable those ports as well. Here's a list of common ports from XAMPP:
The following ports are needed for a basic functionality:
Apache - 80 (HTTP)
Apache HTTPS - 443 (HTTPS/SSL)
MySQL - 3306
And for all other services in XAMPP:
FileZilla FTP - 21
Apache WebDAV - 81
FileZilla Admin - 14147
Mercury SMTP - 25
POP3 - 110
IMAP - 143
HTTP - 2224
Finger - 79
PH - 105
PopPass - 106
Tomcat AJP/1.3 - 8009
Tomcat HTTP - 8080
5.) Once you're finished entering the ports you need, click Save Settings or whatever it's called in your router.

6.) Now go back to the Status tab and find your public IP.

Now enter it into your browser and press enter.
![]()
If all goes well and everything is configured properly, you should be able to reach your website via your external IP address.
If you need help finding your external IP address, go to a website like http://www.whatismyip.com/ and it will be displayed there.
You should see the index page of your website.
If you get some sort of error, then it's probably because of at least these three basic possible reasons:
1. Your Windows Firewall is blocking it.
See the section below on how to check and configure this properly.
2. You've got something configured wrong.
Make sure you have the correct IP address for your computer and it's typed correctly. Verify you also have the ports forwarded correctly.
3. Your ISP (Internet Service Provider) has port 80 blocked. Click here to read on how to fix this.
Some ISP's block port 80 probably because they don't want people running public servers from their home. You can call and check with them to see if this is the case if everything else doesn't seem to work for you. Be sure to also check your terms of service agreement with your ISP, because many of them do not allow you to host a web server on your internet connection.
If the above three doesn't resolve your issue, you might try searching around using Google for articles pertaining to your router model or ISP to see if other's are having the same issue. This is often the best way to find and solve issues outside the basic ones listed above.
Opening Ports In Windows Firewall
The easiest way to test and see if your issue is from Windows Firewall blocking your ports, Try turning off Windows Firewall and then retry connecting to your server. If you can connect, then this is where your problem is. Here's how to fix it.
** BE SURE TO TURN YOUR FIREWALL BACK ON!! **
1.) In Vista, go to your Windows Security Center. Now select Windows Firewall on the left.
In XP, go to Control Panel, then select Windows Firewall.
I'm using Windows Vista for this demonstration, so your's may look slightly different.
2.) In Vista, click Allow a program through Windows Firewall on the left side.

In XP, click on the Exceptions tab as shown below.

3.) Look for the program in the list and make sure it's not unchecked.
If it's not listed there, then click Add Port.

Fill out the information accordingly and then click OK.
If you click on Change Scope, you can specify which IP addresses are able to connect to that port. This is probably a great choice for making a FTP connection more secure, but you must know the IP address for the computer you will be connecting to the server with.
You should be done now. If everything was set correctly, it should work. Either do a search for any further issues or post in the forums and I will try to help and update this tutorial if neccessary.
ADDITIONAL NOTES
If you still are unable to connect to your web server after doing everything listed here, then you could have a setting wrong in your server configuration. Try connecting to your server locally via http://127.0.0.1 or http://localhost again and make sure you can connect.
** SECURITY WARNING **
Opening ports to your computer poses a threat and a risk of being attacked by a hacker. I recommend doing some research and reading to better understand these risks and how to take measures against protecting yourself against such attacks.
How to forward port 80 if blocked by ISP
If your ISP is blocking port 80 or you want to have multiple servers on the same IP address, you can easily forward traffic to your website on port 80 to another port on your router. You can do this one of two ways that I know of.
1 - Using your IP address. If you don't own a domain name and you're just using your IP address, you simply add on the port you wish to use to the end of it. For example, http://123.12.12.143:5000 . the ":5000" would be the port I chose to use. You also need to make a few slight changes to your Apache configuration file. Read below on how to do that. You can set it to any available port, just make sure you forward it correctly in your router and firewall as stated in the instructions above.
2 - Using your Domain Name. You can either use a free domain from no-ip.com or if you own one, you can use my preferred choice, ZoneEdit.com. You can read more about how to setup and configure either one of those by reading this article.
REQUIRED CHANGES TO APACHE'S CONFIGURATION FILES FOR USING PORTS OTHER THAN 80.
By default, Apache is configured to listen on port 80 only. If you are using a different port, you must tell Apache to listen on that new port.
Depending on if you are using VirtualHosts or not, there's one or two places you will need to make changes.
The first one is in your /xampp/apache/conf/extra/httpd.conf file.
Find the following line:
Listen 80
Now change 80 to the correct port. For example, let's say I'm using port 2000 instead:
Listen 2000
Next, find this line and change 80 to your new port:
ServerName localhost:80
You can specify multiple ports for Apache to listen on if neccessary by creating new lines for each new port. Here's an example:
Listen 80
Listen 2000
This will make Apache listen on both ports 80 and 2000.
You are done now unless you are using VirtualHosts. If so, you need to do the following steps in your VirtualHost entries.
To access your website, you would simply type http://localhost:2000/
VirtualHost Changes
First, you need to specify the new port for NameVirtualHost. You will need a new instance of it for each port Apache is to Listen on. Here's an example of Apache listening on two ports:
NameVirtualHost *:80
NameVirtualHost *:2000
You can specify particular IP's for it to listen on. Let's say you want to have port 2000 only listen on IP 192.168.1.111 and port 80 to listen for all incoming traffic. Here's how you would do that:
NameVirtualHost *:80
NameVirtualHost 192.168.1.111:2000
So now in order for someone to access a virtual host defined to Listen on port 2000, they must specify port 2000, otherwise they will only access the entries using port 80. Also, they can only access the port 2000 VirtualHost if they have access to IP 192.168.1.111.
Now you need to specify the correct port in your VirtualHost entry. Here's an example:
<VirtualHost *:2000>
ServerAdmin
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
DocumentRoot C:/xampp/htdocs
ServerName mydomain.com
</VirtualHost>
Now to access the site, you would enter the correct domain name with the port # after it.
http://mydomain.com:2000/
That's it!
Now I have noticed in some cases, some scripts won't work on other ports besides 80. I encountered this problem particularly when trying to run Vidiscript on a different port and I do not know a fix for it.
* To find your computer's network name, do this:
In Vista, right-click on Computer and then select Properties and it will be under Computer name, domain, and workgroup settings.
For XP, right-click on My Computer, select Properties, and then click the "Computer Name" tab.
Last Updated (Monday, 14 September 2009 01:51)







