Allow public connections to local Ruby on Rails Development Server

I am setting up a RoR development environment on a Windows machine. I was wondering how I can set it up so a few friends of mine can have access to the web server and monitor the progress?

It would only be 2 or 3 people connecting at anytime time max.


Solution 1:

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.)

Solution 2:

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.

Solution 3:

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.

Solution 4:

As someone suggested, use ngrok.

It's stupidly easy.

Solution 5:

Allow remote connections by binding the Rails server to 0.0.0.0.

Here's the short notation for those who don't like typing 😊:

bin/rails s -b 0.0.0.0

If you also want to allow IPv6 connections (Puma):

bin/rails s -b [::]