Trick #1: Listen on any Interface

Recent versions of Rails lock down the interface to localhost. This prevents users on your local network from accessing your network. You may not want to do this however. For example, you may wish to share your development site with a coworker so that he/she can review the site. Likewise, 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.

Terminal Commands:

rails s -b

Trick #2: Use a Different Port

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

Terminal Commands:

rails s -p 3001

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

Trick #3: Run in a Different Environment

Did you know you can start a rails server for another environment such as production or test? This can be very handy if you have other custom environments set up. Simple use the -e argument along with the name of the environment you wish to start up in.

Terminal Commands:

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.

Thanks for reading!