Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNREFUSED using Docker Container #256

Closed
alescofet opened this issue Jan 6, 2025 · 5 comments
Closed

ECONNREFUSED using Docker Container #256

alescofet opened this issue Jan 6, 2025 · 5 comments
Labels
triage This ticket will be looked at shortly

Comments

@alescofet
Copy link

Description

When trying to navigate to a url it gives me this error:
Error: connect ECONNREFUSED 127.0.0.1:36957
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 36957
}

Full steps to reproduce the issue

This is my dockerfile:
FROM ghcr.io/puppeteer/puppeteer:22

USER root

RUN apt-get update &&
apt-get -y install sudo &&
adduser pptruser sudo &&
echo "pptruser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER root
RUN sudo apt-get update && apt-get install -y
wget
gnupg
ca-certificates
apt-transport-https
xvfb &&
rm -rf /var/lib/apt/lists/*

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list &&
apt-get update &&
apt-get install -y google-chrome-stable &&
rm -rf /var/lib/apt/lists/*

ENV PORT=5000
ENV MONGO_URI=
ENV ENV=prod

RUN mkdir -p /home/pptruser/Downloads /app &&
chown -R pptruser:pptruser /home/pptruser &&
chown -R pptruser:pptruser /app

USER pptruser
COPY package.json /app
RUN npm install
COPY . /app

EXPOSE 5000
ENTRYPOINT ["/usr/local/bin/node", "/app/server.js"]

And this is my script:

async function launchPuppeteer() {
const {browser,page} = await connect({

headless: false,

args: [],

customConfig: {},

turnstile: true,

connectOption: {},

disableXvfb: true,

ignoreAllFlags: false

})
return {browser,page}
}

async function refreshLink(url) {
const Game = connectCollection('scrap-cd-romance', 'Game')
const {browser, page} = await launchPuppeteer()
await page.goto(url);
console.log(await page.content());
await page.click("button.acf-get-content-button");
await page.waitForSelector("#acf-content-wrapper a");
const html = await page.content();
}

Issue Type

Bug

Operating System

Linux

Do you use Docker?

Docker

@alescofet alescofet added the triage This ticket will be looked at shortly label Jan 6, 2025
@RubberArchind
Copy link

I think because your base image was Puppeteer, it conflicted with this library somehow.

@alescofet
Copy link
Author

Already tried with node base image and still gives me the same error

@nlgthuan
Copy link

nlgthuan commented Jan 8, 2025

@alescofet I meet the same issue and installing xvfb as node dependency fixed the problem.

@faisalferoz
Copy link

@alescofet set disableXvfb to false in connect argument, then it will run in docker as it needs XVFB to run.

@mdervisaygan
Copy link
Member

this problem should be fixed. Please let me know if it persists in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage This ticket will be looked at shortly
Projects
None yet
Development

No branches or pull requests

5 participants