How to access localhost of computers outside the network

In this guide, I’m going to show you how you can access the localhost of other computers outside or inside your home network.

This guide is specifically intended for people who are working on a website which needs testing from users. Because most of the time the programmer will not see all of the programs defect, errors, or bugs. And only the users can point this out.

 

Wired Connection

For those of you who have wired connection. The method of letting others access your projects for testing purposes would be much more easier. To do this, just go to cmyip.com. Then copy your ip address. Paste it into the address bar of your browser. If you can see something like the screenshot below then it works for you, but were still not sure if it would work for others. So to try it out, just give your ip address to your friends and let them do the same:

image

If it doesn’t work for them. Then maybe who have somehow messed up with your firewall configurations. I won’t recommend you to try and disable it. Because that’s stupid.

To do that, just go to your control panel, and then click on windows firewall. Then click on restore defaults.

image

It will warn you that restoring defaults might cause other programs to not function properly. That’s why I recommend that you create a restore point first. After creating a restore point, just click on restore defaults.

image

Next thing that you need to do is to ensure that ip addresses from outside the network would have access is to configure your http.conf file. Just left click on the wampserver tray icon then select apache, then click on httpd.conf.

image

If its your first time opening the file, then it would prompt you to select a program that you will use to open the file. Just select notepad from the list.

Now, press ctrl+H on your keyboard to launch the find and replace tool in notepad. And type:

</di

image

You have to modify the part enclosed in <directory> tags. Replace the Deny from all with Allow from all. The text enclosed in <directory> tags will now look like this:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

Just save that one and then restart your wampserver. Others should now have access to your localhost, and they can now test your projects.

Last thing that you’ll need to do is to make sure that you’re server is actually online.

image

If you can see that the text in there is Put Offline. Then yours is already online. And ready for access from the outside world.

If you want to protect your codes from being downloaded. Then you have to put index.php file on every folder of your project. Be it javascript or css. But the most important are the php files.

If you didn’t then your testers might see something like this:

image

And its not cool. I’m telling you. Because if they see that one. They can download it.

 

Wireless Connection

This part of this guide is intended for those who have laptops or desktop which connects to the internet via router or wireless hotspots or wi-fi. The ip address that the people from outside the network will use to access your localhost is the ip address that you can see in cmyip.com.

There are few things that you need to do which I already mentioned at the top. So do these things first before you continue:

  • Edit your httpd.conf
  • Make sure your server is already online

If you’ve done that then fire up your command line by typing cmd on the search bar.

Type in ipconfig/all

You’ll see something like this(Sorry but if I’m taking precautions here. I’m not actually gonna show you whats my ip address and everything:

image

You’ll only be concerned with the value of the ipv4 address in here. Just paste that ip address into your browsers address bar. If it doesn’t work then you might need to configure your router as well.

Here’s how to configure your router. Just go type 192.168.1.1 or 192.168.1.0  on your browsers address bar to access your router settings.  The usual username and password would be admin.

Go to forwarding, then add the ip address which you have copied from the command line a while ago. And paste it into the textbox which requires the ip address. Then type 80 on the port. Port 80 is the port that is commonly used. But if you’re accessing your web directory through a different port, then use that port. Make sure you enable this configuration so that the port forwarding will work.

 

Conclusion

That is how you access localhost from other computers. Its just easy and I think it’s a nice tool for letting others see and test your work without having to host it on an actual server.

2 thoughts on “How to access localhost of computers outside the network

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s