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.

Connecting to a chrome instance running in a docker container through puppeteer locally and opening a localhost page

See original GitHub issue

I am running headless chrome in a docker container and accessing it through puppeteer by running it locally using browerWSEndpoint. This part works fine. Once I get the connection established I try to use the instance to go to a localhost:port which fails and I get the following error:

Error: net::ERR_CONNECTION_REFUSED at http://localhost:port/ at navigate (path_to/node_app/puppet/node_modules/puppeteer/lib/Page.js:521:37) at anonymous at process._tickCallback (internal/process/next_tick.js:188:7)

  • Puppeteer version:^1.2
  • Platform / OS version: My puppeteer is running on my local machine which is MacOS 10.13.4 and the docker container is linux.
  • Node.js version: v8.11.2
  1. I used the following for setting up headless chrome in my container. (Note: Didnot use the app folder but only chrome)
  2. Used puppeteer to connect to this chrome instance.
  3. Tried to open a localhost:<port>.

await page.goto("http://localhost:<port>", {waitUntil: 'networkidle0'});

Expected: Connection established and docker container stopping.

Actual: Error: net::ERR_CONNECTION_REFUSED at http://localhost:port/ at navigate (<path>/node_app/puppet/node_modules/puppeteer/lib/Page.js:521:37) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
meghs94commented, Jun 25, 2018

Docker local isnt same as machine local. I used the hostname and it worked.

0reactions
salinaaaaaacommented, Mar 24, 2020

Docker local isnt same as machine local. I used the hostname and it worked. @meghs94 Is it the hostname of the docker container or the host the containers are running on?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connecting to a chrome instance running in a docker ... - GitHub
I am running headless chrome in a docker container and accessing it through puppeteer by running it locally using browerWSEndpoint.
Read more >
Localhost connection refused when accessing headless ...
Tried to open a localhost using: await page. goto("http://localhost:port", {waitUntil: 'networkidle0'}); Expected: Connection established and  ...
Read more >
How to use Puppeteer inside a Docker container
The easiest path to use Puppeteer inside a Docker container is installing Google Chrome because, in contrast to the Chromium package offered by...
Read more >
Docker Configuration - browserless docs
The browserless docker container is highly-configurable, and accepts parameters through ... You can access this information by running the command below:
Read more >
Troubleshooting - Jest
To debug in Google Chrome (or any Chromium-based browser), open your browser and go to chrome://inspect and click on "Open Dedicated DevTools ...
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