When running multiple headless Watir browser scripts in parallel, in Ruby, if you do not specify a different display number, every script will try to access the same browser window and will occasionally cause an error related to not being able to access a port.
The solution is simple, you need to provide a display number for your headless code, replacing a code like this:
Headless.ly do begin end end
with this version:
Headless.ly(:display => 3) do begin end end
where the number given for display must be different for every simultaneous headless script you’ll run.