Firefox won’t work in headless mode

firefoxscreenshot

When I try to use FF headless to take a screenshot of a website by:

firefox -screenshot google.com

FF refuses to run with the following error message:

*** You are running in headless mode.
Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

I am running FF 58.0.2.

How do I fix this?

Best Answer

As the error message tries to say (I get the more explanatory "A copy of Firefox is already open. Only one copy of Firefox can be open at a time."), you cannot have more than one Firefox running at a time using the same profile. One simple solution would be to create a separate profile for screenshots (run once with firefox -P to create such a profile, I named mine "screenshots", for example), and then explicitly use the new profile when attempting to create screenshots:

firefox -screenshot google.com -P screenshots

You may additionally need -no-remote, as reported by Stack of Pancakes in a comment.

Related Question