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?

- 91
- 1
- 7
1 Answers
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:
- (Windows)Open the commandprompt (start -> search cmd.exe or run and enter cmd) // (Linux/Unix/Mac)Open a terminal
- (Windows)run ip-config and look for the line that specifies your IPv4 address, write it down if you have to // (Linux/Unix/Mac)run ifconfig and look for the line stating inet. Either way, this address probably looks like 192.168.X.Y
Next, check to see if Apache is listening
- As this is often the default setting, it probably is. So grab any other device connected on the same network and open a browser
- In the address bar type the 192.168.X.Y IP address of the PC running XAMPP
- If you don't see an error, go to your files and enjoy!
- If you do get an error, change the config for Apache (httpd.conf) and search for a line containing "Listen 80", if you can't find it then it's probably listening to 0.0.0.0:80 and you need to edit that line to "Listen 80" as that will allow it to listen to all addresses on the network.
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
- Go to Control Panel > Windows Firewall > Allow a program to communicate through windows firewall > Add another program Name: http Port: 80
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.

- 440
- 3
- 13
-
1damn I never thought about this, thanks mate it worked with same network – JJ D. Lordes Jul 11 '18 at 22:40
-
@JJ D. Lordes can't blame you, a lot of people don't think of it when they're just getting started with running servers on their network. Although I will say that running the server on the system you develop on might make loading times horrible, so of you have a spare (ancient) system, I recommend you set up a simple web server on that and push the files there when it needs testing on mobile devices. Debian gives the option to install as an Apache webserver on a clean install, which makes a great test case for a real world server (most are Linux running Apache/nginx) – RivenSkaye Jul 13 '18 at 06:32