Click here to Skip to main content
15,567,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello can't use proxy in python selenium browser
browser gives this error and then closes ("ERR_TUNNEL_CONNECTION_FAILED")

my code:
Python
myoptions = uc.ChromeOptions()
            myoptions.add_argument(f'--proxy-server=http://'+ str(proxyc))
            myoptions.add_argument('--lang=tr')
            myoptions.add_argument('--disable-popup-blocking')
            myoptions.add_argument('--no-sandbox') 
            myoptions.add_argument('--disable-gpu')
            myoptions.add_argument('--disable-dev-shm-usage')
            driver = uc.Chrome(use_subprocess=True, options=myoptions)
            wait = WebDriverWait(driver, 20)


Error Message:
Python
Traceback (most recent call last):
  File "c:\Users\kSalih\Desktop\ADV Blog\CookieVar.py", line 168, in <module>
    driver.get(lines[0])
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 543, in get
    return super().get(url)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 441, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_TUNNEL_CONNECTION_FAILED
  (Session info: chrome=107.0.5304.107)
Stacktrace:
Backtrace:
        Ordinal0 [0x008FACD3+2075859]
        Ordinal0 [0x0088EE61+1633889]
        Ordinal0 [0x0078B7BD+571325]
        Ordinal0 [0x00787CD2+556242]
        Ordinal0 [0x0077EC5D+519261]
        Ordinal0 [0x0077FAEC+522988]
        Ordinal0 [0x0077EF27+519975]
        Ordinal0 [0x0077E2EB+516843]
        Ordinal0 [0x0077E231+516657]
        Ordinal0 [0x0077D0A3+512163]
        Ordinal0 [0x0077D5AD+513453]
        Ordinal0 [0x0078D0CE+577742]
        Ordinal0 [0x007EBC7D+965757]
        Ordinal0 [0x007D731C+881436]
        Ordinal0 [0x007EB56A+963946]
        Ordinal0 [0x007D7136+880950]
        Ordinal0 [0x007AFEFD+720637]
        Ordinal0 [0x007B0F3F+724799]
        GetHandleVerifier [0x00BAEED2+2769538]
        GetHandleVerifier [0x00BA0D95+2711877]
        GetHandleVerifier [0x0098A03A+521194]
        GetHandleVerifier [0x00988DA0+516432]
        Ordinal0 [0x0089682C+1665068]
        Ordinal0 [0x0089B128+1683752]
        Ordinal0 [0x0089B215+1683989]
        Ordinal0 [0x008A6484+1729668]
        BaseThreadInitThunk [0x7749FEF9+25]
        RtlGetAppContainerNamedObjectPath [0x77E57BBE+286]
        RtlGetAppContainerNamedObjectPath [0x77E57B8E+238]

Exception ignored in: <function Chrome.__del__ at 0x0000021F2731B600>
Traceback (most recent call last):
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 657, in __del__
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 645, in quit
OSError: [WinError 6] İşleyici geçersiz
Exception ignored in: <function Patcher.__del__ at 0x0000021F272B87C0>
Traceback (most recent call last):
  File "C:\Users\kSalih\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\patcher.py", line 273, in __del__
OSError: [WinError 6] İşleyici geçersiz


What I have tried:

I added wait with sleep code vs still it didn't work

i tried this code:
Python
myProxy = "http://149.215.113.110:70"

        proxy = Proxy({
        'proxyType': ProxyType.MANUAL,
        'httpProxy': myProxy,
        'ftpProxy': myProxy,
        'sslProxy': myProxy,
        'noProxy':''})


and this:
Python
proxy = Proxy({
    'proxyType': ProxyType.MANUAL,
    'httpProxy': myProxy,
    'sslProxy': myProxy,
    'noProxy': ''})

options = Options()
options.proxy = proxy


but proxy not changed
Posted
Comments
Dave Kreskowiak 16-Nov-22 0:12am    
Does you proxy require authentication?
kSalih54 16-Nov-22 1:50am    
no it does not ask for authorization

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900