Getting NewConnectionError while connecting with seleniumwire chrome on amazon EC2 instance

I am getting this error frequently not everytime.

HTTPConnectionPool(host=’localhost’, port=32817): Max retries exceeded
with url: /session/286f9b1508aa3fab78fee8a606577194/execute/sync
(Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection
object at 0x7fd56e845400>: Failed to establish a new connection:
[Errno 111] Connection refused’))

When I send request again, it works. But doesn’t work when I send subsequent requests.

What i am doing wrong.

I am using these Chrome options.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> proxies: dict = {
"httpProxy": proxy_string
}
options.proxy = Proxy(proxies)
# Other Chrome options
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors')
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument("--incognito")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
options.add_argument("--start-maximized")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-extensions")
options.add_argument("--no-zygote")
options.add_argument("--disable-notifications")`
</code>
<code> proxies: dict = { "httpProxy": proxy_string } options.proxy = Proxy(proxies) # Other Chrome options options.add_argument("--no-sandbox") options.add_argument("--headless") options.add_argument('--ignore-certificate-errors') options.add_argument("--disable-gpu") options.add_argument("--disable-software-rasterizer") options.add_argument("--incognito") options.add_argument("--disable-dev-shm-usage") options.add_argument("--window-size=1920,1080") options.add_argument("--start-maximized") options.add_argument("--disable-popup-blocking") options.add_argument("--disable-extensions") options.add_argument("--no-zygote") options.add_argument("--disable-notifications")` </code>
    proxies: dict = {
        "httpProxy": proxy_string
    }
    options.proxy = Proxy(proxies)

    # Other Chrome options
    options.add_argument("--no-sandbox")
    options.add_argument("--headless")
    options.add_argument('--ignore-certificate-errors')
    options.add_argument("--disable-gpu")
    options.add_argument("--disable-software-rasterizer")
    options.add_argument("--incognito")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--window-size=1920,1080")
    options.add_argument("--start-maximized")
    options.add_argument("--disable-popup-blocking")
    options.add_argument("--disable-extensions")
    options.add_argument("--no-zygote")
    options.add_argument("--disable-notifications")`

Using Chrome version as 126.0.6478.55

Please let me know if any further info required.

I have tried hitting request again and again. Sometimes its working and sometimes giving exception.

I am doing one thing here

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@staticmethod
def is_instance_valid(instance):
try:
instance.execute_script("return true;")
logging.info("Browser instance is valid")
return True
except WebDriverException:
logging.error("Browser instance is invalid")
return False
</code>
<code>@staticmethod def is_instance_valid(instance): try: instance.execute_script("return true;") logging.info("Browser instance is valid") return True except WebDriverException: logging.error("Browser instance is invalid") return False </code>
@staticmethod
    def is_instance_valid(instance):
        try:
            instance.execute_script("return true;")
            logging.info("Browser instance is valid")
            return True
        except WebDriverException:
            logging.error("Browser instance is invalid")
            return False

Can this piece of code does this?

I am downloading chrome and driver version like this in my docker file.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] http://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
# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt
RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp
RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& rm -rf /tmp/chromedriver-linux64.zip
</code>
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && echo "deb [arch=amd64] http://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 # Check Chrome installation RUN echo google-chrome --version RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp RUN unzip /tmp/chromedriver-linux64.zip -d /tmp RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && chmod 0755 /usr/local/bin/chromedriver && rm -rf /tmp/chromedriver-linux64.zip </code>
RUN apt-get update && apt-get install -y wget gnupg2 curl unzip 
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 
    && echo "deb [arch=amd64] http://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

# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt

RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp

RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver 
   && chmod 0755 /usr/local/bin/chromedriver 
   && rm -rf /tmp/chromedriver-linux64.zip

New contributor

sudhanshu saini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

10

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Getting NewConnectionError while connecting with seleniumwire chrome on amazon EC2 instance

I am getting this error frequently not everytime.

HTTPConnectionPool(host=’localhost’, port=32817): Max retries exceeded
with url: /session/286f9b1508aa3fab78fee8a606577194/execute/sync
(Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection
object at 0x7fd56e845400>: Failed to establish a new connection:
[Errno 111] Connection refused’))

When I send request again, it works. But doesn’t work when I send subsequent requests.

What i am doing wrong.

I am using these Chrome options.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> proxies: dict = {
"httpProxy": proxy_string
}
options.proxy = Proxy(proxies)
# Other Chrome options
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors')
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument("--incognito")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
options.add_argument("--start-maximized")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-extensions")
options.add_argument("--no-zygote")
options.add_argument("--disable-notifications")`
</code>
<code> proxies: dict = { "httpProxy": proxy_string } options.proxy = Proxy(proxies) # Other Chrome options options.add_argument("--no-sandbox") options.add_argument("--headless") options.add_argument('--ignore-certificate-errors') options.add_argument("--disable-gpu") options.add_argument("--disable-software-rasterizer") options.add_argument("--incognito") options.add_argument("--disable-dev-shm-usage") options.add_argument("--window-size=1920,1080") options.add_argument("--start-maximized") options.add_argument("--disable-popup-blocking") options.add_argument("--disable-extensions") options.add_argument("--no-zygote") options.add_argument("--disable-notifications")` </code>
    proxies: dict = {
        "httpProxy": proxy_string
    }
    options.proxy = Proxy(proxies)

    # Other Chrome options
    options.add_argument("--no-sandbox")
    options.add_argument("--headless")
    options.add_argument('--ignore-certificate-errors')
    options.add_argument("--disable-gpu")
    options.add_argument("--disable-software-rasterizer")
    options.add_argument("--incognito")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--window-size=1920,1080")
    options.add_argument("--start-maximized")
    options.add_argument("--disable-popup-blocking")
    options.add_argument("--disable-extensions")
    options.add_argument("--no-zygote")
    options.add_argument("--disable-notifications")`

Using Chrome version as 126.0.6478.55

Please let me know if any further info required.

I have tried hitting request again and again. Sometimes its working and sometimes giving exception.

I am doing one thing here

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@staticmethod
def is_instance_valid(instance):
try:
instance.execute_script("return true;")
logging.info("Browser instance is valid")
return True
except WebDriverException:
logging.error("Browser instance is invalid")
return False
</code>
<code>@staticmethod def is_instance_valid(instance): try: instance.execute_script("return true;") logging.info("Browser instance is valid") return True except WebDriverException: logging.error("Browser instance is invalid") return False </code>
@staticmethod
    def is_instance_valid(instance):
        try:
            instance.execute_script("return true;")
            logging.info("Browser instance is valid")
            return True
        except WebDriverException:
            logging.error("Browser instance is invalid")
            return False

Can this piece of code does this?

I am downloading chrome and driver version like this in my docker file.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] http://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
# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt
RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp
RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& rm -rf /tmp/chromedriver-linux64.zip
</code>
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && echo "deb [arch=amd64] http://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 # Check Chrome installation RUN echo google-chrome --version RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp RUN unzip /tmp/chromedriver-linux64.zip -d /tmp RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && chmod 0755 /usr/local/bin/chromedriver && rm -rf /tmp/chromedriver-linux64.zip </code>
RUN apt-get update && apt-get install -y wget gnupg2 curl unzip 
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 
    && echo "deb [arch=amd64] http://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

# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt

RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp

RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver 
   && chmod 0755 /usr/local/bin/chromedriver 
   && rm -rf /tmp/chromedriver-linux64.zip

New contributor

sudhanshu saini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

10

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật