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

HTTPS_PROXY not working #1544

Closed
2 tasks done
hbagdi opened this issue Dec 5, 2023 · 1 comment
Closed
2 tasks done

HTTPS_PROXY not working #1544

hbagdi opened this issue Dec 5, 2023 · 1 comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!

Comments

@hbagdi
Copy link

hbagdi commented Dec 5, 2023

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

1.export HTTPS_PROXY="https://username:password@my.proxy.example.com"
2. http http://httpbin.org
3. error

Current result

http: error: ProxyError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 426 Upgrade Required'))) while doing a GET request to URL: https://httpbin.org/ip

Expected result

The request should work

Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

$ HTTPS_PROXY="https://username:password@my.proxy.example.com" http --debug https://httpbin.org/ip

HTTPie 3.2.2
Requests 2.31.0
Pygments 2.16.1
Python 3.11.6 (main, Oct  2 2023, 13:45:54) [GCC 11.4.0]
/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/bin/python3.11
Linux 6.2.0-37-generic

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7f38e07a2480>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x7f38e07a2340>,
 'colors': 8,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/hbagdi/.config/httpie'),
 'devnull': <property object at 0x7f38e07ac130>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7f38e07a23e0>,
 'program_name': 'http',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x7f38e07a6cd0>,
 'rich_error_console': <functools.cached_property object at 0x7f38e07a7350>,
 'show_displays': True,
 'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
 'stderr_isatty': False,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

<PluginManager {'adapters': [<class 'httpie_unixsocket.UnixSocketTransportPlugin'>],
 'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
          <class 'httpie.plugins.builtin.DigestAuthPlugin'>,
          <class 'httpie.plugins.builtin.BearerAuthPlugin'>],
 'converters': [],
 'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
                <class 'httpie.output.formatters.json.JSONFormatter'>,
                <class 'httpie.output.formatters.xml.XMLFormatter'>,
                <class 'httpie.output.formatters.colors.ColorFormatter'>]}>

>>> requests.request(**{'auth': None,
 'data': RequestJSONDataDict(),
 'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.2.2')>,
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x7f38e0310540>,
 'url': 'https://httpbin.org/ip'})


http: error: ProxyError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 426 Upgrade Required'))) while doing a GET request to URL: https://httpbin.org/ip


Traceback (most recent call last):
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 700, in urlopen
    self._prepare_proxy(conn)
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 994, in _prepare_proxy
    conn.connect()
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/urllib3/connection.py", line 369, in connect
    self._tunnel()
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/http/client.py", line 926, in _tunnel
    raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
OSError: Tunnel connection failed: 426 Upgrade Required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 785, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 426 Upgrade Required')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hbagdi/.linuxbrew/Homebrew/bin/http", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/__main__.py", line 9, in main
    exit_status = main()
                  ^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/core.py", line 162, in main
    return raw_main(
           ^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/core.py", line 136, in raw_main
    handle_generic_error(propagated_exc, annotation=annotation)
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/core.py", line 100, in raw_main
    exit_status = main_program(
                  ^^^^^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/core.py", line 213, in program
    for message in messages:
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/httpie/client.py", line 113, in collect_messages
    response = requests_session.send(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hbagdi/.linuxbrew/Homebrew/opt/python@3.11/lib/python3.11/site-packages/requests/adapters.py", line 513, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 426 Upgrade Required')))

Additional information, screenshots, or code examples

The connection to the proxy itself must be HTTPS - this is non-negotiable.
When HTTP_PROXY is set (where the connection to the proxy is HTTPS), I can use proxy with non-HTTPS traffic (http http://httpbin.org).

@hbagdi hbagdi added bug Something isn't working new Needs triage. Comments are welcome! labels Dec 5, 2023
@Ousret
Copy link
Collaborator

Ousret commented May 21, 2024

The issue mentioned here is most likely due to an error on either the proxy or the client configuration.
Tunnel connection failed: 426 Upgrade Required is a clear hint toward steps that should be taken.

@Ousret Ousret closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

2 participants