SeleniumHQ/selenium · error · Selenium::Server::Error
remote server not ready in {} seconds
Error message
remote server not ready in {} seconds What it means
Raised by Selenium::Server#poll_for_ready (server.rb:281) when the server has not returned a healthy status before @timeout seconds elapse. It polls status_ok? every 0.5s and gives up once elapsed exceeds the configured timeout (default 30s).
Source
Thrown at rb/lib/selenium/server.rb:281
if @log.is_a?(String)
cp.io = @log
elsif @log
cp.io = :out
end
cp.detach = @background
cp
end
end
def poll_for_ready
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
loop do
return if status_ok?
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time
raise Error, "remote server not ready in #{@timeout} seconds" if elapsed > @timeout
sleep 0.5
end
end
def socket_connected?
@socket_connected ||= socket.connected?
end
def poll_for_shutdown
return if socket.closed?
raise Error, "remote server not stopped in #{@timeout} seconds"
end
def socket
@socket ||= WebDriver::SocketPoller.new(@host, @port, @timeout)
endView on GitHub (pinned to aa36b38e69)
Solutions
- Increase the timeout: Selenium::Server.new(jar, timeout: 120).
- Inspect the server log (pass log: 'server.log' or log: true) for the startup error.
- Ensure the port is free and Java is on PATH with a compatible version.
- Run the server in the foreground (background: false) to see the failure immediately.
Example fix
# before server = Selenium::Server.new(jar, background: true) # default timeout 30 # after server = Selenium::Server.new(jar, background: true, timeout: 120, log: true)
Defensive patterns
Strategy: retry
Validate before calling
require 'socket'
raise 'port 4444 already in use' if TCPSocket.new('127.0.0.1', 4444)
# and ensure java is present:
raise 'java not on PATH' unless system('java -version', out: '/dev/null', err: '/dev/null') Try / catch
begin
server = Selenium::Server.new(jar, background: true, timeout: 120, log: true)
server.start
rescue Selenium::Server::Error => e
raise unless e.message.include?('not ready')
raise "server failed to start; see #{server.log}"
end Prevention
- Increase timeout: on slow/CI hosts (e.g. timeout: 120).
- Ensure the port is free and Java is on PATH with a compatible version.
- Run with log: true and inspect the server log when startup fails.
When it happens
Trigger: poll_for_ready loops; status_ok? never becomes true within @timeout (default 30) seconds, so it raises 'remote server not ready in N seconds'.
Common situations: Slow/CPU-constrained CI; Java missing or wrong version; port 4444 already in use; the server crashed during startup (check the server log); a large Grid startup under memory pressure.
Related errors
- remote server not stopped in #{@timeout} seconds
- Can not connect to the Service {self._path}
- {} for {}
- {}
- -> #{@pid} still alive after #{timeout} seconds
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/195563bd0fe9ed25.
Report an issue: GitHub.