Lighthouse CI in github action fails to run with error: ERR_CONNECTION_REFUSED
See original GitHub issueDescribe the bug I run Lighthouse CI in my github action and it fails with an error. I used the same configuration in my local environment and it worked fine.
To Reproduce Steps to reproduce the behavior:
- Use the following Lighthouse configuration file:
module.exports = {
ci: {
collect: {
numberOfRuns: 3,
startServerCommand: 'yarn run start',
url: ['http://localhost'],
},
assert: {
preset: 'lighthouse:recommended',
},
upload: {
target: 'temporary-public-storage',
},
},
};
-
Insert a Lighthouse package.json script to run:
"lighthouse": "lhci autorun"
-
Insert a Lighthouse step in Github action file:
name: Snippet
on:
pull_request:
branches: [ main ]
jobs:
test_pull_request:
name: Testing & Checking the code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Installing dependencies
run: yarn install --immutable --immutable-cache --check-cache
- name: Check build command
run: yarn run build
- name: Lighthouse Benchmark
run: yarn run lighthouse
Run it in GH and watch it failing (at-least for me…)
Expected behavior Run without any issue
Logs/Screenshots
Error: Lighthouse failed with exit code 1
at ChildProcess.<anonymous> (/home/runner/work/landing-page/landing-page/node_modules/@lhci/cli/src/collect/node-runner.js:120:21)
at ChildProcess.emit (events.js:400:28)
at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
Thu, 03 Mar 2022 21:34:47 GMT LH:ChromeLauncher Killing Chrome instance 2161
Runtime error encountered: Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Details: net::ERR_CONNECTION_REFUSED)
error Command failed with exit code 1.
Environment (please complete the following information):
- OS: Ubuntu
- Browser: Chrome
- Version: Unknown
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
Top Results From Across the Web
Getting error (ERR_CONNECTION_REFUSED) #339 - GitHub
If it's a localhost or dev server URL, that usually just means the server crashed or isn't running anymore. If it's a public...
Read more >Running lighthouse-ci/cli 0.8.2 in github action unable to ...
Describe the bug. I try to run @lhci/cli@0.8.2 in a github action in headless mode and it is unable to connect to chromium....
Read more >"Unable to load the page" · Issue #2784 - GitHub
Within Lighthouse, this error comes from gatherRunner.assertPageLoaded. ... Solution: Restart Chrome and run Lighthouse again.
Read more >Unable to connect to Chrome · Issue #698 - GitHub
Unable to connect to Chrome If you're using lighthouse with --skip-autolaunch, make sure you're running some other Chrome with a debugger.
Read more >Unable to successfully run Lighthouse CI with GitHub Actions ...
Running Lighthouse 3 time(s) on http://localhost:34541/index.html Error: Lighthouse failed with exit code 1 Run #1...failed! at ChildProcess.< ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AshNaz87
So the problem occurred because the server ran on port “80” in the Github Action machine. Apparently port “80” is protected to root permissions, so either run “sudo yarn run start” or open the server with other port. Something like “8080”. I took the second option.
@AshNaz87
I do have a custom server. That’s why I needed it. Anyway- this works fine. But yet, I have the issue only in the github action been running.
Really strange because I just followed known guides. Nothing special in my configuration