question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lighthouse CI in github action fails to run with error: ERR_CONNECTION_REFUSED

See original GitHub issue

Describe 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:

  1. 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',
		},
	},
};
  1. Insert a Lighthouse package.json script to run: "lighthouse": "lhci autorun"

  2. 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:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
tal-rofecommented, Mar 26, 2022

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

0reactions
tal-rofecommented, Mar 9, 2022

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found