1

My current setup is Rails on the backend, React Native on the front end. According to other questions, I know that I need to use the address 10.0.3.2 to access localhost from within Genymotion (10.0.2.2 if you're on the default Android emulator).

How do I allow incoming connections for my Rails server?

maxhm10
  • 1,034
  • 9
  • 20

2 Answers2

3

In order to do this, follow these steps:

  1. By default, your Rails server does not accept connections outside of your local machine (remember that the emulator is independent from your computer when it comes to networking). So you need to bind your server to 0.0.0.0 to accept connections from anywhere:

rails s --binding=0.0.0.0

  1. To test that the previous setup is working, go to your browser in your emulator and type in 10.0.3.2:3000. You should see the equivalent of typing localhost:3000 in your browser in your computer.
maxhm10
  • 1,034
  • 9
  • 20
0

Just simple, you can do these steps as below:

  • First, you type this command in order to show your ip address: ifconfig
  • Second, in your console, type this command: rails s -b your_ip_address
    • For example: rails s -b 192.168.1.102
  • Finally, open browser on your android and type: 192.168.1.102:3000

You can read this rails official to understand clearly.

rails host

Khanh Pham
  • 2,848
  • 2
  • 28
  • 36