title: Capybara Connection Refused
body: <p>I am using Capybara with Selenium in Ruby (not within a testing framework.)</p>
  
  <p>If I open a ruby console and run the method, it works, but if i then run the same method again I get this error.</p>
  
  <pre><code>    Errno::ECONNREFUSED: Connection refused - connect(2)
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `open'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:762:in `connect'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:744:in `start'
  from /home/ross/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/http.rb:1284:in `request'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/capybara-2.0.1/lib/capybara/selenium/driver.rb:34:in `visit'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/capybara-2.0.1/lib/capybara/session.rb:180:in `visit'
  from /home/ross/.rvm/gems/ruby-1.9.3-p327/gems/capybara-2.0.1/lib/capybara/dsl.rb:51:in `block (2 levels) in &lt;module:DSL&gt;'
  </code></pre>
  
  <p>The code is like the following:</p>
  
  <pre><code>class ExampleClass
    include Capybara::DSL
  
    def do_capybara
  
      Capybara.app_host =  "http://example.com"
      Capybara.run_server = false
      Capybara.current_driver = :selenium
  
      visit '/'
  
      page.driver.browser.close
  
      Capybara.reset_sessions!
    end
  </code></pre>