4 When using the CDP-based Remote Agent in Firefox, there are
5 three different programs/components running simultaneously:
7 * the __client__, being the out-of-process script or library
8 (such as Puppeteer) or web inspector frontend you use to control
9 and retrieve information out of Firefox;
11 * the __agent__ that the client connects to which is an HTTPD living
12 inside Firefox, facilitating communication between clients
15 * and the __target__, which is the web document being debugging.
17 Since Firefox 86 the Remote Agent ships in all Firefox releases by default.
19 To check if your Firefox binary has the Remote Agent enabled, you
20 can look in its help message for this:
24 --remote-debugging-port [<port>] Start the Firefox Remote Agent, which is
25 a low-level debugging interface based on the CDP protocol.
26 Defaults to listen on localhost:9222.
29 When used, the Remote Agent will start an HTTP server and print a
30 message on stderr with the location of the main target’s WebSocket
33 % firefox --remote-debugging-port
34 DevTools listening on ws://localhost:9222/devtools/browser/7b4e84a4-597f-4839-ac6d-c9e86d16fb83
36 `--remote-debugging-port` takes an optional port as input:
40 You can use this to instruct the Remote Agent to bind to a particular
41 port on your system. port is optional,
42 which means `firefox --remote-debugging-port` will bind the HTTPD to
43 the default `localhost:9222`.
45 If port has been specified the default port will be overridden:
47 % firefox --remote-debugging-port 9989
48 DevTools listening on ws://localhost:9989/devtools/browser/b49481af-8ad3-9b4d-b1bf-bb0cdb9a0620
50 When you ask the Remote Agent to listen on port 0,
51 the system will atomically allocate an arbitrary free port:
53 % firefox --remote-debugging-port 0
54 DevTools listening on ws://localhost:59982/devtools/browser/a12b22a9-1b8b-954a-b81f-bd31552d3f1c
56 Allocating an atomic port can be useful if you want to avoid race
57 conditions. The atomically allocated port will be somewhere in the
58 ephemeral port range, which varies depending on your system and
59 system configuration, but is always guaranteed to be free thus
60 eliminating the risk of binding to a port that is already in use.
62 [Firefox Nightly]: https://www.mozilla.org/en-GB/firefox/channel/desktop/#nightly