ruby-on-railsbrowservagranthostsmongrel

rails 2.3 server running inside vagrant environment not accessible in host machine mac os x browsers


in vagrant I am using:

box 'prorail/centos-5.8-x86_64'

in vagrant i am running rails 2.3 server like:

[vagrant@localhost myapp]$ script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

in my hosts file i have added this line at the bottom

192.168.60.110    www.example.dev example.dev dev.example.com

in Vagrantfile i have added this ip:

config.vm.network :private_network, ip: "192.168.60.110"

in all browsers i have tried following urls

dev.example.com:3000/
dev.example.com

in browser nothing happens . i hav tried all browsers

chrome  
tor  
firefox  
safari

i have tried several other commands to run rails 2.3 server inside vagrant environment but still nothing happens

script/server -b 0.0.0.0
script/server -b 0.0.0.0 -p 3000
script/server -p 3000

Solution

  • log into vagrant environment:

    vagrant ssh
    

    than type or copy/paste the following command:

    sudo /sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
    

    this command will allow port to be accessible by host machine. than type:

    exit
    

    login again into vagrant and goto your project root. than run:

    script/server
    

    now you can access it in browser

    www.example.dev