Hi, I am on CentOS 7 with google-chrome installed (version 59) and node version 8.2.1
I run this code
const chromeLauncher = require('chrome-launcher');
chromeLauncher.launch({
startingUrl: 'https://google.com',
chromeFlags: ['--headless', '--disable-gpu']
}).then(chrome => {
console.log(`Chrome debugging port running on ${chrome.port}`);
});
and it will return error like this.
(node:31716) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:33416
(node:31716) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I don't undestand that error, why it can't connect to that port? Is there any special settings needed on network side?
Thanks in advance.
specify a port like 8001 to try?
@sonyarianto, I was experimenting the same issue on Chrome 60 and adding --no-sandbox flag solved the problem.
const chromeLauncher = require('chrome-launcher');
chromeLauncher.launch({
startingUrl: 'https://google.com',
chromeFlags: ['--headless', '--disable-gpu', '--no-sandbox']
}).then(chrome => {
console.log(`Chrome debugging port running on ${chrome.port}`);
});
Can you confirm you OS also @carloslfu? I believe that --no-sandbox will be required on *nix with --headless at the moment.
Is CentOS 7
@carloslfu Yes, it solve my problem by adding --no-sandbox
@carloslfu How do you even figure that out??? I mean, thank you, but like how
Hello @zwhitchcox . I found the solution by using command line e.g. lighthouse https://google.com. Then this error is shown: No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
Ok, haha, I've never actually used the command lighthouse before..just using headless chrome...so i guess you know a lot more than I do haha
I didn't had luck with the command lighthouse - same error as carloslfu. I did had luck using lightouse programmatically and passing --no-sandbox to chromeLauncher.launch() - if possible I would recommend to add this flag to documentation since this blocks new users :( thanks
Thanks for reporting. I'm tracking this issue as https://github.com/GoogleChrome/chrome-launcher/issues/6 so I'll dupe this to there.
@cancerberoSgx You can do so via the command line, just pass the flags to --chrome-flags, like so:
lighthouse <url> --chrome-flags="--no-sandbox --headless --disable-gpu"
So, I am trying this...
$ lighthouse https://google.com --chrome-flags="--no-sandbox --headless --disable-gpu"
...and getting this error...
ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:36200 +2ms
ChromeLauncher:error Logging contents of /tmp/lighthouse.5Epzmdr/chrome-err.log +0ms
ChromeLauncher:error [20412:20412:0619/112922:ERROR:browser_main_loop.cc(219)] Running without the SUID sandbox! See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the sandbox on.
ChromeLauncher:error [20412:20412:0619/112922:ERROR:browser_main_loop.cc(271)] Gtk: cannot open display:
ChromeLauncher:error +0ms
Unable to connect to Chrome
...Is this the same issue or something different?
It's the same class of error @mhenniger, ECONNREFUSED means Chrome didn't start properly and/or crashed.
The log messages you have indicate --headless isn't being respected. What version of Chrome are you running?
OMG... So you you asked a great question. Using npm to install lighthouse gave me chrome-launcher, but not chrome itself!!!! I am doing this work in Ubuntu. I just tried "sudo npm install chrome -g" but it seems to think I am on a mac, so I removed that. Do you have any recommendations for installing everything needed for lighthouse CLI? Thanks in advance for any tips you can provide. This is all new to me.
@patrickhulce ^
How to install Chrome is a bit beyond the scope and purpose of GitHub issues :) but you can take a look at the download script we use for an up-to-date Chrome version in CI and try Stack Overflow if you're still having trouble getting the basic environment setup.
Most helpful comment
@sonyarianto, I was experimenting the same issue on Chrome 60 and adding
--no-sandboxflag solved the problem.