How to Run Localhost on Your Mobile Phone - A Step-by-Step Guide
Jide Abdul-Qudus
Software Engineer (Full-Stack) | UK Global Talent | Startup & Innovation
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>
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:
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:
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
Computer Engineering Student
3 个月Easiest way. Thank You.
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!
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.
Full-Stack Web Developer at Eclipse DOT | Aspiring to be a renowned Software Engineer someday
1 年thanks brother
Software Engineer, Web developer
1 年what about if we use a vpn in computer, should we use the same vpn on the phone right?