how to view "localhost" on my iPod touch

To expand slightly on Richard J. Ross III's answer, "localhost" is a name used to refer only to the local computer. In order for your iPhone to be able to access content on that machine it must:

  1. Have an IP address on the same network as the server machine.

    This can be achieved by connecting the iPhone to a wireless access point that is on the same network as the PC, or by creating an ad-hoc wireless network between the two devices.

  2. Respond to HTTP requests from network clients.

    Assuming the server and the iPhone are on the same network, it should be possible for traffic to flow between them. However in order for your web content to be visible to the iPhone, the web server must also be configured to respond to requests made to the server machine's IP address.

    This is not normally a problem as web servers are commonly configured to respond to HTTP requests sent to any of the machines IP addresses. It is possible that a server could be configured to only respond to local requests, however this is not a typical default setting

    How you check or modify this setting is dependent upon the HTTP server software you are using. As this information is not specified I will include instructions for Apache2 as this is a very common choice of HTTP server.

Apache's Listen Directive

Apache's main configuration file is httpd.conf and it is located in the conf subdirectory of your Apache directory. The location of your Apache root directory will vary depending upon what operating system you are using and whether or not a custom location was chosen at installation.

The httpd.conf file contains a directive named Listen which controls the interface (IP address and port) on which Apache listens for incomming HTTP requests.

The default form of this directive is commonly

Listen 80

This specifies that the machine will respond on any of it's IP addresses to requests made on port 80, which is the default port for HTTP traffic.

You can modify the Listen directive to use any address associated with the machine including the loopback address (127.0.0.1) which the name localhost resolves to.

If Apache is set up to only listen on the loopback address then your server machine will only respond to requests made on the local machine. In this configuration, your Listen directive will look something like:

Listen 127.0.0.1:80

If this is the case, you will need to change to either listening on all addresses, as in the example above, or listening only on the address used by the iPhone to communicate with the server machine.


Assuming that your development machine is called my-macbook-pro, you should just be able to navigate to http://my-macbook-pro.local/mywebsite on your iPhone.


I'm working with xampp. localhost works on port 8080. I just find my ip with ipconfig and surf to http://10.0.0.1:8080. That easy!


100% working solutions

(for linux + apache + vhosts)

If you are using vhost (several sites on the same server apache) the next several tips can help you view your local websites on mobile:

1) VHOST edit -You should go to /etc/apache2/sites-available/ on your server. There can be several files .conf, each file contain a virtual host configuration for apache. Default file will look like 000-default.conf. Open it (or another one) with admin permissions sudo. In that file you should see something like this:

 <VirtualHost *:80>
        ServerName auction.dev
        ServerAdmin [email protected]
        DocumentRoot /var/www/public_html/html
        ErrorLog /var/www/logs/error.log
        CustomLog /var/www/logs/access.log combined
 </VirtualHost>

2) XIP.IO - this special service (its totally free) can help you. You should add to .conf file next line - ServerAlias auction.dev.*.xip.io, after this operation your file will look like this:

<VirtualHost *:80>
            ServerName auction.dev
            ServerAlias auction.dev.*.xip.io
            ServerAdmin [email protected]
            DocumentRoot /var/www/public_html/html
            ErrorLog /var/www/logs/error.log
            CustomLog /var/www/logs/access.log combined
</VirtualHost>

After editing you should save this file and restart apache with command sudo apachectl restart.

3) View from mobile - You need to know ip of your server, in my situation ip = 192.168.1.247. Now in your mobile browser just type auction.dev.192.168.1.247.xip.io and you should see your local website.