How to change Rails default development server port
October 22nd, 2008
| Tags: rails
If you work on multiple rails apps at once (eg. an app and a webservice), it is sometimes necessary to run rails development apps on a different ports. You can of course do this when you start the rails app by adding the -p
But here is a way to set the default development port per app. Update script/server to look like this:
#!/usr/bin/env ruby
default_port = 3001
if RAILS_ENV='development'
ARGV << "-p#{default_port}" unless ARGV.to_s.include?("-p")
end
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'

Great thanks! Just a fix:
if RAILS_ENV=’development’
should be
if ENV['RAILS_ENV'] == ‘development’
This doesn’t seem to work for me running rails 2.3.5. Has this worked for you on that version? Any thoughts on why it might not work or another way to do it?