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
I used the https://github.com/skalfyfan/dockerized-puppeteer for setting up headless chrome in my container. (Note: Did not use the app folder but only chrome) Used puppeteer to connect to this chrome instance. Tried to open a localhost using: 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 (/node_app/puppet/node_modules/puppeteer/lib/Page.js:521:37)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
Thank you.
Fixed it. I used hostname -f
on terminal to find the hostname and used it instead of localhost. I think there is no localhost mapping when launching chrome instance from docker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With