DEV Community

Ian
Ian

Posted on

Sharing Your Localhost with Other Devices Easily

Want to show your local website to others on your network, like a co-worker or on your phone? It's simple if you're using Ruby on Rails. Here's how:

Set Up Rails Server for Network Access

By default, the Rails server is only visible to your own computer. To let other devices see it, start the server with this command:

rails server -b 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

This makes your server accessible to any device on your network.

Find Your Computer's Network IP Address

Open your terminal and type:

ifconfig | grep 'inet'

You'll see a list. Look for an entry like inet 10.194.110.231 netmask .... Here, 10.194.110.231 is your IP address.

Share Your Site

Now, other devices can access your site using your IP address followed by :3000 (the default Rails server port). For example:

http://10.194.110.231:3000

Done!

That's it! Your site should now be accessible from other devices on the same network.

Top comments (0)