ruby script/server is not working

hi everyone i just typed ruby script/server -d and then after when i type again it is not working. i got this error

[2012-02-09 16:19:54] WARN TCPServer Error: Address already in use - bind(2) Exiting /usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)   from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new'   from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'   from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each'   from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'   from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'   from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'   from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'   from /usr/lib/ruby/gems/1.8/gems/rack-1.1.3/lib/rack/handler/ webrick.rb:10:in `new'   from /usr/lib/ruby/gems/1.8/gems/rack-1.1.3/lib/rack/handler/ webrick.rb:10:in `run'   from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb: 111   from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'   from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'   from script/server:3 thanks in advance

TCPServer Error: Address already in use

that error message claims you have already running some server on the same port as you're trying to run this on. cancel/shutdown other one or add "-p some_number" to run your server on different port


This mean that port which is required for your application is already using by your machine.

Yon need to kill this process either your can use

ruby script/server -p 1234

Then you can be able to run your application on http://localhost:1234

One more thing, if you are using linux OS then you can kill your existing running process-

kill process_id process_id : this id you have to collect from Linux UI process monitor, see ruby process id and use above command.

Best luck

Right. You told your server to go into "daemon mode" (that's what the -d did), which is why it *seemed* to exit. Technically the process you started did exit -- but it started another, which is what's still using that address (port). You can't run another copy of the server unless you either kill the current one or use a different port. Otherwise, the system wouldn't know which of the two should answer if someone tries to connect to that port.


hi everyone i just typed rails s and then after when i

type again it is not working. i got this error

Usage: rails new APP_PATH [options]

Options: -r, [–ruby=PATH] # Path to the Ruby binary of your choice # Default: C:/RailsInstaller/Ruby1.9.2/bin/ruby .exe -b, [–builder=BUILDER] # Path to a application builder (can be a files ystem path or URL) -m, [–template=TEMPLATE] # Path to an application template (can be a fil esystem path or URL) [–skip-gemfile] # Don’t create a Gemfile [–skip-bundle] # Don’t run bundle install -G, [–skip-git] # Skip Git ignores and keeps -O, [–skip-active-record] # Skip Active Record files -S, [–skip-sprockets] # Skip Sprockets files -d, [–database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3 /jdbcpostgresql/jdbc) # Default: sqlite3 -j, [–javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library # Default: jquery -J, [–skip-javascript] # Skip JavaScript files [–dev] # Setup the application with Gemfile pointing t o your Rails checkout [–edge] # Setup the application with Gemfile pointing t o Rails repository -T, [–skip-test-unit] # Skip Test::Unit files [–old-style-hash] # Force using old style hash (:foo => ‘bar’) on Ruby >= 1.9

Runtime options: -f, [–force] # Overwrite files that already exist -p, [–pretend] # Run but do not make any changes -q, [–quiet] # Supress status output -s, [–skip] # Skip files that already exist

Rails options: -h, [–help] # Show this help message and quit -v, [–version] # Show Rails version number and quit

Description: The ‘rails new’ command creates a new Rails application with a default directory structure and configuration at the path you specify.

You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.

Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.

Example: rails new ~/Code/Ruby/weblog

This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.

Thanks in advance.

Since your'e not the original poster, I assume this is a separate issue?

Did you create an app first and then 'cd' into that new directory?

My guess is that he's trying to point out how -d means daemonize, yielding exactly the behavior the OP complained about.