7

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?

  • 1
    Re: "Firefox is already running", do you indeed have another running instance of Firefox? – dhag Feb 20 '18 at 21:50
  • Do you already have running instances of `firefox`? – DopeGhoti Feb 20 '18 at 21:50
  • 1
    Yes, I do. I use FF in a normal mode to browse the web. Is this a problem? I thought the browser in headless mode was supposed to work alongside 'normal' instances running. – 0x400921FB54442D18 Feb 20 '18 at 21:51
  • Well, it appears to be having trouble communicating with itself. Try terminating all currently-running copies of Firefox, and running the command again. Presuming that it works, go ahead and start an interactive session again, and try your command yet once more. – DopeGhoti Feb 20 '18 at 21:54

1 Answers1

6

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.

dhag
  • 15,440
  • 4
  • 54
  • 65