Running a ruby on rails project on my mac. I need to test it on my android phone. Is there a way to view my mac localhost on my android phone?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
Chunk's answer is correct, assuming your mobile device and your computer are on the same network. However, if you want your localhost server to be visible to the wider Internet (e.g. for testing over 3G, developing webhooks or collaboration with a remote colleague/client), more is needed as local addresses (starting with 10.* or 192.168.*) are not visible to the wider Internet.
The traditional solution to that is port forwarding and dynamic DNS, but lately a few services have popped up which aim to make this process simpler (disclaimer: I am the author of one of them, PageKite).
These services provide you with a public DNS name and software which connect your "localhost" with an in-the-cloud relay server (a.k.a. a reverse proxy). For example, if you are using PageKite, you can run the following command in the terminal:
$ pagekite.py 80 yourname.pagekite.me
... to create a mapping from
http://yourname.pagekite.me/
to the web server running onhttp://localhost:80
. While the program is running, your localhost site will be visible to the rest of the Internet. In order to make it private again, you simply turn off the pagekite.py connector program.For completeness, here are some of the localhost tunneling services I am aware of:
(Sorry about not linking to the last two, SO spam protection is preventing me from being fair to my competitors. ;-)
Although one answer has been accepted but this worked for me:
ifconfig
inside terminal and look foren0/en1 -> inet
it should be something like19*.16*.1.4
.)Open your mobile settings and go to network-> long press your wifi network-> modify network -> scroll down to advanced options -> chose proxy manual and in proxy hostname type your address i.e.
19*.16*.1.4
inside port enter your port. and save it.search for
what is my ip
in google chrome, and get your ip, lets say it is1**.1**.15*.2**
1**.1**.15*.2**:port/
from your mobile device.It is as simple as this.
This worked for me for accessing rails server with IP over local network:
/etc/hosts should have this entry:
where 192.168.100.12 is the ip address which can be found by ifconfig command in terminal.
Start rails server with this command:
I was able to access my localhost through http://192.168.100.12:8080/
MacOS Catalina 10.15.4