4

If I specify port number separately the specified port number working.

rails s -p 3005 now its working with localhost:3005

But when i use - rails s - it running as localhost:3000.

why ruby-on-rails choosing default port is 3000.

suresh gopal
  • 3,138
  • 6
  • 27
  • 58

3 Answers3

8

It really doesn't matter which port (as long as it's above 1024 (those below are privileged ports and you must be root to use them).

If you don't like port 3000 you can change it How to change Rails 3 server default port in develoment?

Community
  • 1
  • 1
graudeejs
  • 349
  • 1
  • 6
1

The Rails server has a few default options, one of which is port 3000. If you don't explicitly set one of these settings, it will use the defaults defined there.

Peter Brown
  • 50,956
  • 18
  • 113
  • 146
0

The temporary solution: />rails server -p 8080



------Complete solution

open rails application under '/config/boot.rb' add code


require 'rails/commands/server'
    module Rails
        class Server
            alias :default_options_alias :default_options
            def default_options
                default_options_alias.merge!(:Port => 8080)
            end   
    end
end

After adding above code resulting on each start of server, it will be start on port: 8080.

Community
  • 1
  • 1
Snm Maurya
  • 1,085
  • 10
  • 12