Boot Up Rails App, Make Request to App from Outside Local Network

Boot up rails app, make request to app from outside local network

You can not bind the socket to your external IP. This IP is assigned to your modem (or whatever you use to connect to the internet) by your ISP. You can only bind to interfaces of your computer.

There are multiple solutions:

  • Bind to 0.0.0.0:3000 (or your computers IP, not localhost) and make sure that your network forwards your public IP to your computer on that port.
  • Use something like https://ngrok.com/ easy and simple

Access webrick/rails from another computer on local network

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

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.

Accessing rails application from another computer which is on different network

There's a gem called localtunnel. The easiest way to share localhost web servers to the rest of the world.

$ gem install localtunnel
$ localtunnel -k ~/.ssh/id_rsa.pub 3000

You should see something like this:

Port 3000 is now publicly accessible from http://8bv2.localtunnel.com ...

Hosting Rails on local network

I have been doing the same thing on a Raspberry pi with several projects.

You can actually treat your local server like an external one. You can deploy on the local server using capistrano.

Just make sure that your app on your local server will be deployed as production, not development. I would also recommend NGINX and unicorn for performance and zero downtime deployment.



Related Topics



Leave a reply



Submit