cypress: Cypress could not connect to Firefox. `Error: cannot open socket` displayed at beginning of running spec
When running cypress with options ‘–headless --browser firefox’, cypress halts at the start of the second spec with message:
Cypress could not connect to Firefox.
An unexpected error was received from Marionette connection:
Error: cannot open socket
To avoid this error, ensure sure that there are no other instances of Firefox launched by Cypress running.
This blocks running all specs in ‘run’ mode Windows 10, Firefox version 72 (64 bit)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 39 (7 by maintainers)
I have the same issue with cypress 4.5.0 running on Linux on a Microsoft hosted agent in Azure Devops.
Edit: I have this when trying to two runs in the same job, so first for chrome then for Firefox. If I run only for firefox it works, so it seems there is something not closed properly from the first run.
Just in case if it helps in debugging, here’s the screenshot of the error I received.
In my case, I had selected Firefox from the dropdown in the Test Runner. And after re-trying it a couple of time, it worked fine.
Apart from this: fantastic that you are working on the Firefox option!
Maybe it will help someone.
instanceId(cypress.CYPRESS_GROUP.TIMESTAMP)--instanceId=INSTANCE_IDinstanceIdtocypress/tmp/firefox/CYPRESS_GROUP.instanceIdnpm run killFirefoxWin(nodejs custom script based on ps-node) got to be executed. It looks forCYPRESS_GROUPin environment (or group field incypress.env.json), if not found - “general” string will be used instead. It tries to find.instanceIdfile and based on instanceId from it - find main firefox process, kill it and check if any other child processes (children are linked to parent process by--channelparameter) exist - will kill them if yes.firefox.exeI know that it is ugly, but I had to make it work.
Same here. Running specs in Firefox from ci resulted in the same errors as described in this issue, as well as (in the timespan of a week) more than 80 running Firefox processes in the task manager eating up memory.
Option
-no-remotehas no effect in a Windows 10 environment. Issue remains. Tested with cypress 4.0.2still having the issue, even after #6400
This should be fixed in #6400. In the meantime, you can pass
-no-remotevia the Browser Launch API while launching Firefox, which should help: https://docs.cypress.io/api/plugins/browser-launch-api.html#Modify-browser-launch-arguments-preferences-and-extensionsThe answer to both questions is ‘no’. I checked beforehand with the Taskmanager that no firefox processes were running. I noticed that after a run with firefox (with only one spec), a number of firefox processes stay present in the Taskmanager. When I run the same spec again with Firefox, without killing these remaining processes, cypress responds with this remark:
The number of remaining Firefox processes have doubled.
Running a spec with headless chrome I see all chrome processes are neatly cleared after the run.
Did not have the opportunity yet to try fix #6400