has many :code_blocks

Random thoughts and postings to keep track of my learning process

Set up vagrant for Rails

leave a comment »


After you have setup vagrant and created your first rails application and forwarded the port from guest to host with:

config.vm.network "forwarded_port", guest: 3000, host: 3000

you may find that by just running “rails server ” on the guest machine won’t really work.

That is, when you try to access the app from the host machine at http://localhost:3000 you get the well known message: “Connection was reset”

Solution:

Make sure you start your app on guest by binding to 0.0.0.0. By default, rails server binds to localhost.

So on guest the correct way to boot up the rails app is

rails server -b 0.0.0.0 -p 3000

Now if you go to host and try to hit the page, you should be presented with your rails app.

Advertisements

Written by nkartcode

23/01/2015 at 12:58 PM

Posted in ruby on rails

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: