Allow Public Connections to Local Ruby on Rails Development Server

Allow public connections to local Ruby on Rails Development Server

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.

How to access the localhost ruby on rails server in internet?

You've started well, but for local LAN only.

  1. For intranet only, you can use your LAN ip.
    Test it from another local machine (same LAN). Hope it works.

If your firewall and machine settings allow you to view on intranet, than go to next step:


  1. For internet,
    first make sure you have your public internet address, by visiting http://api.ipify.org/ > you will see your public IP address. Use it to access your website http://<public_address>:3000/

If it works on intranet, but not on internet, you need to open the port 3000 in your router and forward it to your local machine. (If you have no access to router settings, ask your administrator to help you with this).

Give me more details for a more complete solution.
What OS are you using?

EDIT:

For Windows10 you have to make sure to open the port 3000 in your firewall.

  • Navigate to Control Panel, System and Security and Windows Firewall.
  • Select Advanced settings and highlight Inbound Rules in the left pane.
  • Right click Inbound Rules and select New Rule.
  • Add the port you need to open and click Next.
  • Add the protocol (TCP or UDP) and the port number into the next window and click Next.
  • On the "Profile" step select all 3 (Domain, Private, Public)
  • Select Allow the connection in the next window and hit Next.
  • Select the network type as you see fit and click Next.
  • Name the rule something meaningful (like: Allow incoming connections on port 3000) and click Finish.

To change the default 3000 port use:

rails server -p 8080 to change port

rails server -b 0.0.0.0 to bind 0.0.0.0 address

UPDATE:

When server starts will output to the console, the address:port it listens. example:
Listening on tcp://0.0.0.0:3000 as a development server it can be set to listen on localhost requests only.

To override that settings use:

rails server -p <3030> -b 0.0.0.0 this will listen to all incoming connections on port 3030

For more details on the -p, and -b consult the help:

$ rails server -h
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: localhost
-c, --config=file Uses a custom rackup configuration.
-d, --daemon Runs server as a Daemon.
-e, --environment=name Specifies the environment to run this server under (test/development/production).
Default: development
-P, --pid=pid Specifies the PID file.
Default: tmp/pids/server.pid
-C, --[no-]dev-caching Specifies whether to perform caching in development.
true or false

-h, --help Shows this help message.

Access webrick/rails from another computer on local network

Try running the server on port 80 instead, your firewall is probably blocking port 3000.

How do you host a Ruby on Rails application on a local network, so multiple people can access it?


  1. Since you're on Windows, open up a command line and run ipconfig to find out your local IP. It will be listed under 'IP Address'.
  2. Tell people in your LAN to access http://192.168.x.x:3000 replacing 192.168.x.x by your IP address from step 1.

Access Rails Development Server From A Different Computer

While starting the webrick server specify the IP on which your rails application will run (10.1.10.100 in your case) using -b option, it binds Rails to the specified IP.

rails server -b 10.1.10.100 -p 3000

Access local host from another machine on network in rails 4.2

I solved this by setting the config.asset_host to the address of the host machine. So if the host machine is 192.168.0.17 then in config/development.rb you want the following line:

config.asset_host = '192.168.0.17:3000'

This is not ideal, it means you need to change your development.rb file every time you want to open up your development server by binding it to 0.0.0.0:3000.



Related Topics



Leave a reply



Submit