Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default port of a Rails 4 app?

I know that I can start a rails server on another port via -p option. But I'd like to setup another port per application as long as I start webrick.

Any ideas?

Regards Felix

like image 448
GeorgieF Avatar asked Sep 09 '25 14:09

GeorgieF


1 Answers

Append this to config/boot.rb:

require 'rails/commands/server'

module DefaultOptions
  def default_options
    super.merge!(Port: 3001)
  end
end

Rails::Server.send(:prepend, DefaultOptions)

Note: ruby >= 2.0 required.

like image 131
Yuriy Kharchenko Avatar answered Sep 13 '25 03:09

Yuriy Kharchenko