SeleniumHQ/selenium · error · Selenium::Server::Error

{} for {}

Error message

{} for {}

What it means

Raised by Selenium::Server.download_server (server.rb) when the HTTP response to the server-jar download is not a Net::HTTPSuccess. The message interpolates the HTTP status code and the destination path, e.g. "404 for selenium-server.jar".

Source

Thrown at rb/lib/selenium/server.rb:160

            total = response.content_length
            progress = 0
            segment_count = 0

            response.read_body do |segment|
              progress += segment.length
              segment_count += 1

              if (segment_count % 15).zero?
                percent = progress.fdiv(total) * 100
                print "#{CL_RESET}Downloading #{destination.path}: #{percent.to_i}% (#{progress} / #{total})"
                segment_count = 0
              end

              destination.write(segment)
            end
          end

          raise Error, "#{resp.code} for #{destination.path}" unless resp.is_a? Net::HTTPSuccess
        end
      end
    end

    #
    # The Mode of the Server
    # :standalone, #hub, #node
    #

    attr_accessor :role, :host, :port, :timeout, :background, :log

    #
    # @param [String] jar Path to the server jar.
    # @param [Hash] opts the options to create the server process with
    #
    # @option opts [Integer] :port Port the server should listen on (default: 4444).
    # @option opts [Integer] :timeout Seconds to wait for server launch/shutdown (default: 30)
    # @option opts [true,false] :background Run the server in the background (default: false)

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Retry after a short delay (transient 5xx/429 are common).
  2. Verify the version/URL; download the jar manually from the Selenium releases page.
  3. If rate-limited, authenticate or wait; check http_proxy/HTTP_PROXY settings.
  4. Pre-download the jar and pass its path to Selenium::Server.new so download is skipped.

Example fix

# before
Selenium::Server.download latest, dest  # resp 404
# after: pre-download then reference local jar
server = Selenium::Server.new('/path/selenium-server.jar', port: 4444)
Defensive patterns

Strategy: retry

Validate before calling

require 'net/http'
uri = URI(download_url)
code = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.head(uri.request_uri).code }
raise "preflight HEAD returned #{code}" unless code.start_with?('2')

Try / catch

retries = 0
begin
  Selenium::Server.download latest, dest
rescue Selenium::Server::Error => e
  raise if (retries += 1) > 3 || !e.message.match?(/^[45]\d\d for /)
  sleep 2 ** retries
  retry
end

Prevention

When it happens

Trigger: download_server completes the request but resp.is_a?(Net::HTTPSuccess) is false (server.rb:160), e.g. a 404/403/5xx from github-releases.githubusercontent.com.

Common situations: GitHub release asset moved or renamed; rate-limited (403/429); transient 5xx; proxy returning an error page; the requested version tag does not exist.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/3d30eaa72892d79c. Report an issue: GitHub.