Save 36% for Black Friday! Learn more

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to Access Rails Server from Other Devices on the Same Network?

Abdul Wahab asked in Servers

I’m working with a Ruby on Rails application inside a DevContainer, and I’m trying to access the Rails server running on my localhost from other devices on the same private network. I’ve already tried running the Rails server with the command rails s -b 0.0.0.0, but when I try to access the application from the browser on a second device, it’s not working.

Here are some details about my setup:

  • I’m using DevContainers for my Rails environment.
  • I’ve exposed the necessary container ports to localhost, but still cannot reach the server from another device.
  • The application works fine when accessed from the host machine (the one running the container).

Can anyone suggest what might be causing this issue and how I can access my Rails app from other devices within the same network?

Reply

First you need to bind to 0.0.0.0 when launching your server.
Second you can access your server from remote machine in LAN using your http:// host_ip:port - kinda like http:// 192.168.1.10:3000

Thats how I do development for Rails + Flutter apps

Reply

Thank you, Alex, but I have already tried the approach you mentioned. I also turned off the firewall on my host machine to check if it was blocking the incoming requests. However, I think the issue might be related to the DevContainers setup through WSL 2 and Ubuntu. Do you have any suggestions on troubleshooting this further?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.