Reputation: 91
I wanted to try localhost
in my mobile, so I can see if it is really responsive
cause in the chrome there are only few selections like iPad,etc..
so My PC has a mobile hotspot. Is it possible to share my localhost
to the connected devices?
Upvotes: 3
Views: 11203
Reputation: 1
Step 1: Connect PC and mobile to same hotspot/WIFI.
Step 2: Put your project folder into "htdocs" folder of XAMPP software. (general path:"C:\xampp\htdocs").
Step 3: Start Apache server on XAMPP control panel.
Step 4: Check your pc IPv4 address. (Open command prompt(CMD), then type "ipconfig" press Enter. You will be able to see your IPv4 Address in the showing list.)
Step 5: In your mobile browser, type "/" followed by your PC IPv4 address and then type your project folder name and search.
E.g. let's assume project folder name: "test", PC IPv4: "192.168.12.345":
Type "192.168.12.345/test" on your mobile and search it. (Make sure your file name in the "test" folder is "index.html" or "index.php".)
If your file name is "example.html", then type "192.168.12.345/test/example.html" and search it.
Upvotes: 0
Reputation: 886
Why are you using your PC as mobile hotspot? Isn't there another network that both your PC and other devices can connect to and find each other on?
Either way, localhost
is just a shorthand for the local loopback IP address (127.0.0.1), which is used for a computer to handle network requests to itself. Now, if the other devices can connect to the PC, then all you need to do is find out what your IP address on the local network is, if XAMPP's Apache server is listening for requests on the network and if any local Firewall isn't blocking access.
(Windows)Before you do anything else, make sure Windows IIS isn't running! It occupies the default http port (80) and is going to cause problems if it's there!
First up, figuring out your IP address:
Next, check to see if Apache is listening
Finally, you can't reach it so check if your firewall is blocking access. This is usually Windows firewall not trusting anything that doesn't carry a Microsoft label
If it still doesn't work and you're running Windows, refer to this Stack Overflow question as you are not the first person that has trouble setting things up.
Upvotes: 7