Solvedlighthouse ECONNREFUSED error, I don't understand...

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.

18 Answers

✔️Accepted Answer

@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}`);
});

Other Answers:

@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"

@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

More Issues: