Rails Server Command Line Options

Rails Server Command Line Options


rails [options]

-s, –config-script=path Uses the specified mongrel config script.
-p, –port=port Runs Rails on the specified port. Default: 3000
-b, –binding=ip Binds Rails to the specified ip. Default:
-e, –environment=name Specifies the environment to run this server under (test/development/production). Default: development

Listen on any Interface
By default versions of Rails is localhost, this prevents users on your local network from accessing your network. You may not want to do this however. You may wish to share your development site with coworker so that they can review the site. Otherwise, you may wish to test the site on other devices such as a mobile device. Fortunately you can easily open the rails server up to all interfaces using the -b argument. Simple run the rails s command below:

rails s -b

Use a Different Port
Sometimes you want to use a port other than 3000 for your Rails server. For instance, maybe you need to run multiple Rails servers. You can easily do this with the -p argument:

rails s -p 3001

This command line tells rails to start the server on port 3001 instead of 3000.

Run in a Different Environment
You can start a rails server for another environment such as production or staging by using the -e argument along with the name of the environment you wish to start up in:

rails s -e production

The code above starts the Rails server in the production environment. Very handy when you have custom environments or need to debug something.

So far so good, That’s it!!! See ya!!! :)