I have a Rails site that I'm developing on localhost Ubuntu and I have a mobile. My site is running on http://localhost:3000.
I want to access this directly via my mobile browser not going through the internet.
Is there any way to access it via WiFi or some other way?
Jump to step:Connect both devices to the same network. Find the IP address of your computer. Find the host name of your computer. Open your mobile browser and visit the IP address or host name.
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
Accessing localhost from the iPhone will simply do a loopback / try to connect to itself (If it supports that?). What you need to do is find the IP of your desktop machine (e.g. If Windows, go to the Command Prompt and type ipconfig or go to Network and Sharing Centre and look up connection status .
If your computer is accessible from internet, just enter in your mobile browser:
http://your.ip:3000/
You could also create a local network (via wifi for instance), connect to it with your cell phone and then do the same thing.
If you are using Rails 4.2+, start the server using:
rails server -b 0.0.0.0
(see http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server).
1.) get your local ip by typing:
ifconfig |grep inet
into your shell/terminal. your ip usually looks like this: 192.xxx.xxx.xx
2.) then start the rails server with:
rails server -b 0.0.0.0
3.) your application can now be reached by typing:
192.xxx.xxx.xx:3000
into the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With