View your localhost on any machine

Side Notes:

  • Please correct the category of this post if it’s incorrect.
  • This is not a question, it’s a tip (learned it moments ago and would like to share it).

Hello all, I just learned a very cool trick and quite useful for my website responsive development. Probably some of you know it but it won’t hurt to share it with the community.

Sometimes when I do responsive design, I prefer to view the site on a real mobile instead of a virtual one. Since I have a mobile and a tablet let’s make them useful.

when you want to access your localhost/website from your mobile it gives an error, but let’s change

STEP 1: Find your computer’s IP address.

Windows:

  • open cmd
  • type this command: ipconfig
  • find this number:
    win7ci-cmd-ipconfig-all-dns-server

MAC:

  • open Terminal
  • type this command: ifconfig | grep "inet " | grep -v 127.0.0.1
  • find this number:
    16%20PM

STEP 2: Type that ip on your mobile.

But wait, you have to type the port after that ip address though. my localhost port is 8888
so in my mobile browser I’ll type this: 192.169.8.40:8888

Now you’ll see the “Index of /” page where you see your websites projects.

Enjoy.

1 Like

Was there a Linux version as well as Windows and Mac?

1 Like

well…I never used…a linux in my life…or at least I know I didn’t. So I don’t know. :sweat_smile:

1 Like

The Windows ipconfig equivalent in Unix/Linux is called ifconfig, same as the Mac ifconfig and used in the same way.

So, the instruction for Mac goes for Linux too. :slight_smile:

@Sora, now you know. :slight_smile:

1 Like

I may have done something wrong.

  • I did not navigate to system32 but ran the command from C
  • I have Windows version 10 not version 6
  • I did not enter a port number

Other than ipv6 numbers, I saw three IP numbers.

Two led to SERPs indicating they had something to do with Comcast Constant Guard. The other with Windows Internet Connection Sharing (my VMware adapter)

There may be a way to access my always running localhost server from my tablet over wifi, but I have a feeling your success may be due to luck and it isn’t always as easy as knowing an IP:port number. Maybe an alternative would be to have intranet cable connections?

Entering the IP address I get from ipconfig takes me to the login page for my router not to my localhost.

You should not use the DNS servers address - which indeed will most likely be your router - but the IPv4 address

Also note that this only works when your mobiles is also connected to the same network, and will stop to work once it isn’t anymore.

6 Likes

To add onto what @rpkamp said, it’s because all devices that are connected to the same network can actually be accessed in this way. If you aren’t on the same network, you’ll be seeing something different. You pretty much have to know the local IP addresses to be able to view what those devices may have. You also aren’t required to supply the port number. You can just do something like 192.168.25 and it’ll show up. The only thing I would advise is that if those devices don’t have a localhost server set up, you won’t be seeing anything. I believe you’ll get your default browser error saying it can’t connect to that address.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.