Access webrick/rails from another computer on local network
After making sure your server side firewall is open to the incoming connection on high ports (this is normally true and the default port is 3000, so you probably don't have to do anything) you must also start the server like this:
rails server -b 0.0.0.0
which binds it to the universal address. It binds to localhost
by default.
Using this method you don't have to bind to port 80, but you can like this:
rails server -b 0.0.0.0 -p 80
(If you're using rvm then you may need to use rvmsudo
)
To make this change more permanent edit your config/boot.rb
and add this:
require 'rails/commands/server'module Rails class Server def default_options super.merge(Host: '0.0.0.0', Port: 3000) end endend
Then you should only have to use rails s
rails server -b 0.0.0.0 -p 8000
This worked for me. No firewall issues, and no need to give super user permissions.
Yes, this was a good answer in general:
rails server -b 0.0.0.0
If you use Ubuntu, you probably have to open the port in the firewall:
sudo ufw allow 3000
If your system is running in VirtualBox, you have to check your Network Settings.
In the case of network mode
NAT
you have to click to the extended options and there to Port Forwarding. Add a rule for TCP protocoll, host port 3000 (or any other), and guest port 3000.