I want to go to the site on my computer (rails, http: // localhost: 3000 ) from a mobile phone, everything is connected to wifi

  • ip provider (external, from myip.ru) - 195.184.199.162
  • router ip (gateway) - 192.168.1.1
  • ip mobile phone (internal ip) - 192.168.1.6
  • ip company - inet 192.168.1.92/24

  1. Mobile and PC as it should be ping each other when they are connected to an Internet and do not ping when there is not
  2. the computer comes through the browser to the site via a localhost, 127.0.0.1, BUT NOT THROUGH your internal ip (although in theory it should, right?)
  3. iptables filters are clean
  4. 192.168.1.92a000 c mobile phones cannot be reached (and from a computer as I said)

Question: do I need to open the port via iptables? How to do it?

I tried iptables -I INPUT -p tcp -m tcp —dport 3000 -j ACCEPT , and also a script from here

  • See if your program is listening to other addresses besides 127.0.0.1. how to look, it is written even according to the link given by you. - aleksandr barakin
  • @alexanderbarakin output , apparently not, this is with pure iptables (iptables.sh is not used), which iptables.sh used is srghma
  • Look at the web server configs, what would it happen on all addresses and not only on 127.0.0.1. And iptables probably has nothing to do with it - Mike
  • wow, you were right) @Mike - srghma

2 answers 2

It is worth trying to replace 127.0.0.1 or localhost with 0.0.0.0 in the server settings.

  • No, if you write rails s -b 0.0.0.0 , then it does not enter from the mobile phone. In general, the problem has already been solved, I wrote the answer, thank you) - srghma

Thanks @Mike, the problem was in the web server itself, the solution

rails s -b 192.168.1.92 (computer ip)