Access website on local network through my Android phone

Asked

Viewed 45,344 times

5

I made a site in PHP and Mysql responsive and would like to access it on my Android phone by localhost, I know I have to put my IP on browser but when I send access it appears the following error:

Forbidden You don’t have permission to access/ on this server.

  • What webserver are you using?

  • Assuming you’re using Apache, put Allow from all in an archive .htaccess at the root of the site you are testing. The default instruction for localhost in Apache is to accept connections only from IP 127.0.0.1, that is, the computer that hosts it itself, and your mobile phone will have a different IP at the time of connection.

  • If you are using some type of router (from the net or other carrier) and the real IP is not inside your computer, you will need to redirect port 80 on your router to your computer.

5 answers

10

WAMP Server

If you use the WAMP Server, is quite simple.

  • Click the WAMP icon in the Windows notifications area and click "Put Online":

inserir a descrição da imagem aqui

 

 

- Discover the IP of your computer on your network. To do this, open the command prompt and type ipconfig. Copy the IP that is right after "Ipv4 Address":

inserir a descrição da imagem aqui

 

 

  • Type the IP of your computer in your mobile browser and voilà. You may need to confirm the request in your computer’s firewall:

inserir a descrição da imagem aqui


XAMPP

In XAMPP, edit the file C:\xampp\apache\conf\extra\httpd-xampp.conf

Turn this:

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Require local
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

Therein:

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    #Require local
    #ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

Then restart Apache by XAMPP Control Panel. And test on your phone using the computer’s IP, as shown in the tutorial for WAMP.

3

I’ve come across this error, and I used Apache, and I solved it this way:

In the folder

apache bin.version. x conf\

open the file

httpd.conf

look for the line:

listen 80

And change her to:

listen 0.0.0.0:80

It worked for me, I hope it works for you.

(I highlighted the text this way because the bold wasn’t working for me)

  • If it is company, I will recommend to put the IP of the host machine. Otherwise, an approach listen *:80 would be 'universal'

2

To configure using linux:

1-open the terminal

2-use hostname -I command

3-copy your ip on your mobile phone, in my case: 10.0.0.10:8080. (8080 is the port that will be placed on the server, staying at your discretion).

4-upload the server with in your folder with the php -S 0.0.0.0:8080 command

this command only works in the version higher than or equal to 5.4+

1


After trying what worked for everyone in the researched experiments, unsuccessfully, I discovered that my problem was in blocking by the firewall of Antivirus.

I share a summary of how I was able to access the localhost with XAMPP by android phone. This worked on mobile both for localhost access by Chrome browser and for reading a mysql database in my APP.

Complete process:

  1. Releasing Apache HTTP in the windows firewall or your Antivirus firewall, as the case may be. ###THIS IS THE POINT MANY PEOPLE FORGET ##. In my case, the firewall is controlled by Mcafee Antivirus. Liberando o Apache HTTP Server no firewall do antivirus

  2. Enable or restart Apache in XAMPP.

  3. Your phone must be on the same wi-fi network that XAMPP is on.
  4. Get Ipv4 from PC. On Windows > command prompt (cmd) > ipconfig. Localizando o IPv4 do PC
  5. To test the connection, open the browser on mobile and enter Ipv4. Localhost acessado pelo browser do celular
  6. In your app, include this Ipv4 as appropriate.

That’s it.

-1

Need to use only 2 features in your mobile browser:

  1. Your IP Gateway (Not the local IP)##
  2. Your Apache door##

For Windows:

  • Click the Start Menu button and access the Windows search field. There, type the "CMD" path to access the Command Prompt.
  • At Prompt type ipconfig and press Enter.
  • You will receive as return a list with various information, including your "Standard Gateway".
  • Go to your AMP and copy the Apache port that is in use (8888 recommended)
  • In your mobile browser type your IP Gateway + port. Example: 192.148.16.236:8888
  • All localhost directories will be listed.

For Mac:

  • Open the "System Preferences".
  • Click Networks and select the network of the current connection.
  • Copy the IP that appears in the upper right corner, this is your Gateway.
  • Go to your AMP and copy the Apache port that is in use (8888 recommended)
  • In your mobile browser type your IP Gateway + port. Example: 192.148.16.236:8888
  • All localhost directories will be listed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.