Allow public connections to local Ruby on Rails Development Server
The simplest way requires NO additional installations: just add a single option to your rails server
(or rails s
) command when you start up the server:
rails s --binding=0.0.0.0
The 0.0.0.0
address means "listen to requests from anywhere." On many systems, the default is 127.0.0.1
, which means "listen to requests from localhost only."
(If you don't also specify a -p
or --port
option, then the port shall be 3000
, as usual.)
You can tell your development server to listen on your publicly accessible interface:
If you're running a server via rails server
, you can specify the IP to listen on via -b <ip>
or --binding=<ip>
. By default, the server listens on 0.0.0.0, that is, only for local connections.
Usage: rails server [mongrel, thin, etc] [options]
-p, --port=port Runs Rails on the specified port.
Default: 3000
-b, --binding=ip Binds Rails to the specified ip.
Default: 0.0.0.0
You can instead find out what your machine's network address is and bind to that address instead, but you will have to forward ports and figure out what your publicly routable IP address is on the Internet; this is outside the bounds of Stack Overflow.
Give localtunnel a go. It's a ruby gem so you shouldn't have any problem getting it going:
gem install localtunnel
localtunnel 3000
The first time you do that it'll ask you for an ssh key, but once you've got that set it'll show you the public url that you can share. Anything running on the specified port will get exposed at that url.
Showoff-io looks like a similar service, but I haven't used it so I can't comment. Also, it's paid and requires signup.
As someone suggested, use ngrok.
It's stupidly easy.