When trying to run Headless Chrome on both mac and linux, it fails with the following error
Chrome --headless --disable-gpu https://www.yahoo.com
[0505/072239.922334:ERROR:browser_process_sub_thread.cc(217)] Waited 5 ms for network service
I'm testing with version Google Chrome 74.0.3729.131
There are a few different ways you can run headless Chrome. One option is to run headless Chrome directly from the command line interface (see next section for details). This can be a bit more straightforward as a place to begin. However, the options for what to run from the command line can be limited.
There are a number of headless browser options, but the one I’ll focus on is the headless version of Google Chrome. You can execute and run Google Chrome without the graphical user interface.
Chromeless, as some might not be familiar with, is not only a rich API for driving headless Chrome, but comes with a prescription for how to execute headless work in a production/CI environment. Their take is fascinating: instead of running and managing the binary in your own infrastructure, just do it in AWS lambda.
In contrast, there’s currently two predominant headless Chrome libraries, signaling an already fractured ecosystem ( though hopefully not for long ). Only one comes bundled with a version of Chrome guaranteed to work with it, though at the cost of flexibility.
Try adding some of the following options:
chromeOptions.addArguments("--headless")
chromeOptions.addArguments("--no-sandbox")
chromeOptions.addArguments("--disable-dev-shm-usage")
chromeOptions.addArguments("--disable-gpu")
chromeOptions.addArguments("--disable-features=NetworkService") ##this did it for me
chromeOptions.addArguments("--window-size=1920x1080")
chromeOptions.addArguments("--disable-features=VizDisplayCompositor")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With