How to Run Localhost on Your Mobile Phone - A Step-by-Step Guide
Run Localhost on your Mobile - Jideabdqudus

How to Run Localhost on Your Mobile Phone - A Step-by-Step Guide

Running?localhost?on your mobile phone can be a valuable tool for developers and tech enthusiasts alike. With?localhost, you can test and run applications and websites on your mobile device, without the need for an external server. This of course is a substitute for running the dev-tools mobile emulator provided by chrome, firefox, or other browsers. As there’s nothing that will perfectly imitate an actual mobile browser better than the mobile device itself. This helps in catching mobile-specific bugs before they surface as a problem for users.

In this article, we will provide a step-by-step guide on how to run a?localhost?on your mobile phone, both for Android and iOS devices.


Step 1: Connect your devices to the same network

This is probably the easiest step, all you have to do is make sure your computer is connected to the same wifi network as your mobile devices.

Step 2: Serve your app to Localhost and get the Port

On your computer/laptop, run your app as you usually do and get the localhost address, it is usually in the form?localhost:<port>


Screenshot of Server on Chrome
Screenshot of Server on Chrome

For instance, the port from the image above is?9999.

Step 3: Find your computer's Local IP Address

There are different ways to find the IP address on your machine, to find out the IP address of your computer:

For Mac:

  1. Open System Preferences -> Network
  2. Next to the Status, you should see the IP address. It should write out - “WiFi is connected to WIFI_NAME and has the IP address YOUR_IP.” See how it looks in the screenshot below:

MacOS Network Tab
MacOS Network Tab

Take note of that address, also, bear in mind that It’s common for your Local IP Address to change automatically when your device or other devices connect/disconnect from the network.

For Linux:

Run in your terminal?hostname -I. Or, run:

ifconfig | grep "inet " | grep -v 127.0.0.1        

For Windows:

  1. Select Start > Settings > Network & internet > Wi-Fi and then select the Wi-Fi network you’re connected to.
  2. Under Properties, look for your IP address listed next to IPv4 address.

Great, now that we got our computer’s local IP address, we need to run our app.

Step 4: View the app on your phone

On your mobile device’s browser, you can now navigate to?https://<Local IP Address>:<port number>. For example, If your application is running on?localhost:9999?and your IP address is 172.32.44.160, then on mobile, we navigate to?172.32.44.160:9999

In conclusion, running localhost on your mobile phone is a useful tool for developers and tech enthusiasts. By following these six simple steps, you can easily set up localhost on your mobile device, and test and run applications and websites right on your phone.

?????Learn more about me

?????Connect on LinkedIn

?????Subscribe to my blog




Sandip Katel

Computer Engineering Student

3 个月

Easiest way. Thank You.

回复
Noran Mohamed Zaki

Full-stack developer at IBM

11 个月

Thank you, your article helped me. It worked with me but then gave me Localhost refused to connect on my phone, I'm trying to solve it now but overall it worked!

JIMMY JAYANT

PHP Web Developer | Wordpress

12 个月

Extremely Useful article. I don't know it is that much easy task to connect to xampp localhost on pc from smartphone. I just connected to my php project website from smartphone to pc localhost.

John Moremm Abuyabor

Full-Stack Web Developer at Eclipse DOT | Aspiring to be a renowned Software Engineer someday

1 年

thanks brother

Lautaro Garcia

Software Engineer, Web developer

1 年

what about if we use a vpn in computer, should we use the same vpn on the phone right?

回复

要查看或添加评论,请登录

Jide Abdul-Qudus的更多文章

社区洞察

其他会员也浏览了