You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature or problem you’d like to solve
Right now it's impossible to use GitHub CLI behind a proxy. Even if you have a proxy set up in the OS or in git GitHub CLI it doesn't work
Note: I'm using Windows 10
Proposed solution
Allow to configure the use of a proxy (maybe the same as git). Something like:
gh config set http_proxy https://user:password@host:port
gh config set https_proxy https://user:password@host:port
Reacted by Lubomir Elko, Bit0r, Robert Klohr, AFCMS, Tony Truong, CEVR88, Vegard Haugland, Ronnie Dutta, Lisa, Bran Koprivica and 6 more
But I agree that we should probably support a configuration option for a proxy. Not sure why Go is not picking up or respecting the OS-wide proxy setting.
Reacted by Yasiel Cabrera, Grigorii Entin, Lubomir Elko, Bit0r, Robert Klohr, AFCMS, Oleg Nabiullin, Jizu Sun, Ronnie Dutta, antoniob and 5 more
Is connecting through unix sockets supported? i.e. with curl it would be curl --unix-socket $HOME/.proxy https://github.com.
When the once I got gh auth login to work (nowhere does it say you need to do this from an elevated prompt)...
Without setting the proxy env variable results in "wsarecv: An existing connection was forcibly closed by the remote host." i.e. gh has no notion of the proxy being present.
Setting the proxy env variable in cmd does nothing
Setting the proxy env variable powershell desktop (5.1) results in "proxyconnect tcp: EOF"
Setting the proxy env variable powershell core (7.1.3) results in "proxyconnect tcp: net/http: TLS handshake timeout"
I can get to https://api.github.com/graphql using my browser (I get the API rate limit warning since I am not authenticated) and from a REST client (authenticated) from the same system so the problem is definitely in gh not understanding how to recognize and use a proxy configured at the OS level.
I would also add that tagging this as an enhancement is not correct this is a bug. If you software needs to traverse a network and it can't handle an proxy then it's not ready for production release, at least not for business use. I challenge you to show me a security conscious company today who it not running a either host or network based proxy.
Given that Go supports the HTTP_PROXY and NO_PROXY environment variables, I think the best we can do is document those variables better in our manual; going to rename this issue to reflect that.
@v3gard GitHub CLI mostly makes HTTPS requests (unless to a GitHub Enterprise instance that has been explicitly configured for HTTP). To make gh traffic go through a proxy, use HTTPS_PROXY, not HTTP_PROXY.
But this works! Note that [1] we're using HTTPS_PROXY and [2] we're going through the same proxy server as before (that responds to http and not https).
@v3gard Yeah, the "https" in HTTPS_PROXY refers to the fact that HTTPS requests will be proxied, not to the protocol where the proxy server itself listens on.
> gh auth login -w
failed to authenticate via web browser: Post "https://github.com/login/device/code":
dial tcp xxx.xx.xxx.x:xxx: connectex: A connection attempt failed because the connected party
did not properly respond after a period of time, or established connection failed because
connected host has failed to respond.
(Pasting error message so other people can find the solution above more easily)
If you are using PowerShell you can try like this: [net.webrequest]::DefaultWebProxy = new-object net.webproxy "http://127.0.0.1:10801"
Adding another perspective here: I think it would still be valuable for the GitHub CLI to support a proxy configuration of its own, for ecosystems that require more fine-grained network control. Relying on the "standard" proxy variables means that any other processes launched by the shell running the CLI will also receive that proxy config, which might be undesirable. NO_PROXY helps, but is less robust if the goal is ultimately to only use a proxy for GitHub.
Reacted by Brian Phillips, 快乐的老鼠宝宝, AmirHossein Abdolmotallebi, Tomáš Procházka, DirkRodi, Brian Giori and Saulius Grigaliunas
Adding another perspective here: I think it would still be valuable for the GitHub CLI to support a proxy configuration of its own, for ecosystems that require more fine-grained network control.
For areas where direct access to GitHub is restricted or unstable, it is usually necessary to try several different proxy software simultaneously. Currently, I have tried modifying the proxy using the following method, but it did not work.
C:\Git_Playground\myproject>gh config set http_proxy http://localhost:12345
! warning: 'http_proxy' is not a known configuration key
I learned about http_proxy from #8623 because I also encountered a similar problem when trying to log in (consistent with #8623).
failed to authenticate via web browser: Post "https://github.com/login/device/code": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The system I am using is Windows 11 26020.rs_prerelease.231214-1452, and I have not tried it on other operating systems yet.
But the HTTPS request got aborted somewhere with a RST_STREAM resulting in an empty file and thus an unusable extension without the user (me) knowing what caused it
Additional reproduction on Windows with GitHub CLI 2.101.0:
Direct gh auth login failed at the device-code request with Post "https://github.com/login/device/code": EOF.
The local proxy was Mihomo/Verge on 127.0.0.1:7897, exposing SOCKS5.
Using HTTPS_PROXY=socks5://127.0.0.1:7897 allowed the device flow to complete and the CLI stored credentials successfully.
socks5h://127.0.0.1:7897 was not reliable in the same setup and could fail at the device-code request.
Clearing stale GH_TOKEN/GITHUB_TOKEN variables was also necessary; otherwise gh auth login refused to store credentials and used the environment token instead.
This suggests the documentation should explicitly distinguish HTTPS_PROXY (the proxy for HTTPS requests) from HTTP_PROXY, document SOCKS5 usage on Windows, and explain that stale token environment variables override interactive login. A short troubleshooting section or a first-class proxy setting would make this failure much easier to diagnose.
Activity
mislav commentedon Oct 1, 2020
@YasielCabrera Can you try setting the
https_proxyenvironment variable? In Powershell, that would be:But I agree that we should probably support a configuration option for a proxy. Not sure why Go is not picking up or respecting the OS-wide proxy setting.
YasielCabrera commentedon Oct 1, 2020
@mislav using environment variables in Powershell it works perfectly, thanks
Note: using env vars seems not to work in the CMD
qaisjp commentedon Nov 11, 2020
Is connecting through unix sockets supported? i.e. with curl it would be
curl --unix-socket $HOME/.proxy https://github.com.Oshimarr36 commentedon Mar 20, 2021
Yes Indeed
RobertKlohr commentedon Mar 29, 2021
Same problem here running Windows 10.
When the once I got
gh auth loginto work (nowhere does it say you need to do this from an elevated prompt)...ghhas no notion of the proxy being present.I can get to
https://api.github.com/graphqlusing my browser (I get the API rate limit warning since I am not authenticated) and from a REST client (authenticated) from the same system so the problem is definitely inghnot understanding how to recognize and use a proxy configured at the OS level.I would also add that tagging this as an enhancement is not correct this is a
bug. If you software needs to traverse a network and it can't handle an proxy then it's not ready for production release, at least not for business use. I challenge you to show me a security conscious company today who it not running a either host or network based proxy.ababushk commentedon Sep 10, 2021
@mislav way works, but in my case I did small adjustment described in docker/for-linux#415 - I set proxy URL's protocol to http instead of https
vilmibm commentedon Mar 2, 2022
Given that Go supports the
HTTP_PROXYandNO_PROXYenvironment variables, I think the best we can do is document those variables better in our manual; going to rename this issue to reflect that.[-]Connect through a proxy[/-][+]Document proxy support[/+]v3gard commentedon Oct 6, 2022
I just tried this from bash (in Windows 10), and it does not seem to work. It works as expected with
curl, but notgh.This command is sent to my proxy server:
HTTP_PROXY="http://localhost:8888" curl -s github.comThis command isn't sent to my proxy server:
HTTP_PROXY="http://localhost:8888" gh repo viewmislav commentedon Oct 6, 2022
@v3gard GitHub CLI mostly makes HTTPS requests (unless to a GitHub Enterprise instance that has been explicitly configured for HTTP). To make gh traffic go through a proxy, use HTTPS_PROXY, not HTTP_PROXY.
v3gard commentedon Oct 6, 2022
Thanks @mislav. That did it. One interesting thing to note though.
As mentioned earlier, this doesn't work:
HTTP_PROXY="http://localhost:8888" gh repo viewBut this works! Note that [1] we're using
HTTPS_PROXYand [2] we're going through the same proxy server as before (that responds to http and not https).HTTPS_PROXY="http://localhost:8888" gh repo viewmislav commentedon Oct 7, 2022
@v3gard Yeah, the "https" in HTTPS_PROXY refers to the fact that HTTPS requests will be proxied, not to the protocol where the proxy server itself listens on.
MetRonnie commentedon Nov 8, 2022
This was the reason I was getting
(Pasting error message so other people can find the solution above more easily)
zaevi commentedon Dec 5, 2022
If you are using PowerShell you can try like this:
[net.webrequest]::DefaultWebProxy = new-object net.webproxy "http://127.0.0.1:10801"nmck257 commentedon Jan 18, 2024
Adding another perspective here: I think it would still be valuable for the GitHub CLI to support a proxy configuration of its own, for ecosystems that require more fine-grained network control. Relying on the "standard" proxy variables means that any other processes launched by the shell running the CLI will also receive that proxy config, which might be undesirable.
NO_PROXYhelps, but is less robust if the goal is ultimately to only use a proxy for GitHub.LaoshuBaby commentedon Jan 28, 2024
For areas where direct access to GitHub is restricted or unstable, it is usually necessary to try several different proxy software simultaneously. Currently, I have tried modifying the proxy using the following method, but it did not work.
I learned about
http_proxyfrom #8623 because I also encountered a similar problem when trying to log in (consistent with #8623).The system I am using is
Windows 11 26020.rs_prerelease.231214-1452, and I have not tried it on other operating systems yet.calidion commentedon Nov 17, 2024
since now github only support gh and ssh.
http/https is useless now.
So
ghsocks5proxy support is needed!nmnmcc commentedon Dec 28, 2024
Here’s how to solve the problem elegantly and once and for all:
tprochazka commentedon Oct 7, 2025
I need to use SOCKS5 proxy and I did not find a way how to do that.
There is also #6689 , but it was closed without an answer.
janv8000 commentedon May 4, 2026
The
gh clidoes not gracefully degrade when a proxy should be used, eg. in my corporate environment:But the HTTPS request got aborted somewhere with a RST_STREAM resulting in an empty file and thus an unusable extension without the user (me) knowing what caused it
2667741708 commentedon Sep 21, 2026
Additional reproduction on Windows with GitHub CLI 2.101.0:
gh auth loginfailed at the device-code request withPost "https://github.com/login/device/code": EOF.127.0.0.1:7897, exposing SOCKS5.HTTPS_PROXY=socks5://127.0.0.1:7897allowed the device flow to complete and the CLI stored credentials successfully.socks5h://127.0.0.1:7897was not reliable in the same setup and could fail at the device-code request.GH_TOKEN/GITHUB_TOKENvariables was also necessary; otherwisegh auth loginrefused to store credentials and used the environment token instead.This suggests the documentation should explicitly distinguish
HTTPS_PROXY(the proxy for HTTPS requests) fromHTTP_PROXY, document SOCKS5 usage on Windows, and explain that stale token environment variables override interactive login. A short troubleshooting section or a first-class proxy setting would make this failure much easier to diagnose.