From: Luis Lavena Date: 2009-12-08T11:40:34+09:00 Subject: Re: WEBrick doesn't work (permission/port error) On Dec 7, 6:34 pm, "P. A." wrote: > Hi. > > I get an error when I start a WEBrick server. > > Here's my application. > > # server.rb > # encoding: utf-8 > > require 'webrick' > > class Server >   class << self >     def start(config = {}) >       config.merge(:BindAddress => '0.0.0.0', :Port => 4321) >       server = WEBrick::HTTPServer.new(config) >       trap('INT') { server.shutdown } >     end >   end > end > > Server.start > > $ ruby1.9.2dev server.rb > [2009-12-08 00:21:53] INFO  WEBrick 1.3.1 > [2009-12-08 00:21:53] INFO  ruby 1.9.2 (2009-11-14) [i686-linux] > [2009-12-08 00:21:58] WARN  TCPServer Error: Permission denied - bind(2) > [2009-12-08 00:21:58] WARN  TCPServer Error: Permission denied - bind(2) > /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': > Permission denied - bind(2) (Errno::EACCES) >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/utils.rb:73:in > `new' >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/utils.rb:73:in > `block in create_listeners' >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/utils.rb:70:in > `each' >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/utils.rb:70:in > `create_listeners' >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/server.rb:74:in > `listen' >         from /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/server.rb:62:in > `initialize' >         from > /opt/ruby-1.9.2-dev/lib/ruby/1.9.1/webrick/httpserver.rb:24:in > `initialize' >         from server.rb:24:in `new' >         from server.rb:24:in `start' >         from server.rb:31:in `
' > > When I start it as a root I get another error. > > # ruby1.9.2dev server.rb > [2009-12-08 00:26:18] INFO  WEBrick 1.3.1 > [2009-12-08 00:26:18] INFO  ruby 1.9.2 (2009-11-14) [i686-linux] > [2009-12-08 00:26:23] WARN  TCPServer Error: Address already in use - > bind(2) > > I also get these errors while I use a stable version of Ruby (1.9.1). I > haven't got any other applications working on port 4321. > > Debian GNU/Linux 5.0.3; > Ruby 1.9.1, 1.9.2dev; > WEBrick 1.3.1. > > What is the reason of this bug? > Is not a bug, it clearly indicates that another process/server is already bound to that port. Please verify that your script wasn't running in the background or you using a port that is already in use by other program/service. -- Luis Lavena