Save 36% for Black Friday! Learn more

Running Multiple Rails Server Instances Locally

Chris Oliver

August 13, 2013

Another great post by @rncrtr talks about running multiple versions of the Rails webserver locally. It can be useful for many different things, for example, if you want to test to see if your load balancer is working properly. You can find his original post at his website.

If you are developing more than one rails project at the same time, or just don’t want to change directories and restart the server constantly, here’s how to start more than one instance.

Normally, rails runs on port 3000, and is started like this:

# "rails s" is the same thing as "rails server"
rails s

Then you load http://localhost:3000 in the browser.

Starting another server instance is as easy as running it on another port, like this:

# The -p option specifies the port, in this case we chose 3001
rails s -p 3001

This works for most web servers, WEBrick (the default), thin and others. Be sure to visit the right address when you load your second app in the browser, which will be located at http://localhost:3001.

Rn Crtr
Rn Crtr is the author of devderp.com.

P.S. You might enjoy following me on Twitter.


Comments