[ACCEPTED]-Allow public connections to local Ruby on Rails Development Server-ruby
The simplest way requires NO additional installations: just add a single 7 option to your
rails server (or
rails s) command when you start 6 up the server:
rails s --binding=0.0.0.0
0.0.0.0 address means "listen 5 to requests from anywhere." On many systems, the 4 default is
127.0.0.1, which means "listen to requests 3 from localhost only."
(If you don't also 2 specify a
--port option, then the port shall 1 be
3000, as usual.)
You can tell your development server to 11 listen on your publicly accessible interface:
If 10 you're running a server via
rails server, you can specify 9 the IP to listen on via
-b <ip> or
--binding=<ip>. By default, the 8 server listens on 0.0.0.0, that is, only 7 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 6 out what your machine's network address 5 is and bind to that address instead, but 4 you will have to forward ports and figure 3 out what your publicly routable IP address 2 is on the Internet; this is outside the 1 bounds of Stack Overflow.
Give localtunnel a go. It's a ruby gem so you shouldn't 8 have any problem getting it going:
gem install localtunnel localtunnel 3000
The first 7 time you do that it'll ask you for an ssh 6 key, but once you've got that set it'll 5 show you the public url that you can share. Anything 4 running on the specified port will get exposed 3 at that url.
Showoff-io looks like a similar 2 service, but I haven't used it so I can't 1 comment. Also, it's paid and requires signup.
As someone suggested, use ngrok.
It's stupidly 1 easy.
Allow remote connections by binding the 4 Rails server to 0.0.0.0.
Here's the short 3 notation for those who don't like typing 2 😊:
bin/rails s -b 0.0.0.0
If you also want to allow IPv6 connections 1 (Puma):
bin/rails s -b [::]
More Related questions