Thursday, July 28, 2016

Running rails server... iptables and binds...

Say you want to run your rail server... you type in the command and your rails application is up and running on localhost:3000

Great.

Now you want to access this server from other machine and suddenly you can't seem to access it? Proxy? Firewall?

Well, first things first: iptables. Make sure to add port 3000 to the list

Either edit iptables directly or just add to it. The choice is yours

Option 1:
sudo vi /etc/sysconfig/iptables

Option 2:
sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT 
sudo service iptables save 
 
Now... when you start the server, by default it would bind to 127.0.0.1 address which is not accessing to the outside. Instead, you need to specify eth0 address that is externally accessible, like so

rails server -b <ip of eth0 - using ifconfig to find out what it is>

Hope this helps someone since i personally got stuck trying to figure out why my iptables were not allowing port 3000 to be seen when I had bind issues all along :)

No comments:

Post a Comment