accessing github from behind corporate proxy

This may not be an RStudio question per se, but I think it is just a little bit :slight_smile:

So I'm behind a proxy at work, and I seem to be having issues with two things (so far):

  1. Installing packages from github devtools::install_github() gives me a
Error: Failed to install 'unknown package' from GitHub:
  Failed to connect to api.github.com port 443: Connection refused
  1. I am also unable to use the git functionality inside RStudio (or the terminal inside RStudio): if I try to push, pull, commit or anything else, I get the near same error
fatal: unable to access 'https://github.com/XXX/XXX.git/': Failed to connect to github.com port 443: Connection refused

BUT, I can use git in the shell. So this is the weird part, why would the proxy only be an issue for RStudio but not the terminal?

My sesh info is here:

sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=Slovenian_Slovenia.1250  LC_CTYPE=Slovenian_Slovenia.1250   
[3] LC_MONETARY=Slovenian_Slovenia.1250 LC_NUMERIC=C                       
[5] LC_TIME=Slovenian_Slovenia.1250    
system code page: 1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_2.3.2 usethis_2.0.1 

loaded via a namespace (and not attached):
 [1] knitr_1.31        magrittr_2.0.1    pkgload_1.2.0     R6_2.5.0         
 [5] rlang_0.4.10      fastmap_1.1.0     tools_4.0.4       pkgbuild_1.2.0   
 [9] xfun_0.21         sessioninfo_1.1.1 cli_2.3.1         withr_2.4.1      
[13] htmltools_0.5.1.1 ellipsis_0.3.1    remotes_2.2.0     rprojroot_2.0.2  
[17] yaml_2.2.1        digest_0.6.27     assertthat_0.2.1  lifecycle_1.0.0  
[21] crayon_1.4.1      processx_3.4.5    purrr_0.3.4       callr_3.5.1      
[25] ps_1.6.0          fs_1.5.0          testthat_3.0.2    curl_4.3         
[29] memoise_2.0.0     glue_1.4.2        cachem_1.0.4      evaluate_0.14    
[33] rmarkdown_2.7     compiler_4.0.4    desc_1.3.0        prettyunits_1.1.1

Try defining your proxy settings with httr before using install_github()

library(httr)
set_config(
  use_proxy(url="your.proxy.ip", port="port", username="user",password="password")
)

Thanks @andresrcs , i did come across this solution on the interwebs, but figured this refers to situations where you are behind a private proxy, whereas i am behind a corporate one and not sure what "user" and "password" should refer to in this case? sorry, this really isn't a topic i understand much about :sweat_smile:

Actually, having a private proxy is not very common, this scenario is most common when working in large organizations. If you don't know your proxy credentials, the only solution would be to ask your IT department for them.

EDIT: I forgot to mention that usually your proxy credential are the same as your logging credentials (the ones you use to access your computer), the tricky part would be to get the proxy url and port but you can get those if you dive into your browser's configuration.

1 Like

Thanks - especially for the credential info. Unfortunately it doesn't seem to work..

I have in the meantime found a partial solution, which allows me to download packages from github:

Sys.setenv(http_proxy="http://proxy.gov.si:80")
Sys.setenv(http_proxy_user="http://proxy.gov.si:80")
Sys.setenv(https_proxy="http://proxy.gov.si:80")
Sys.setenv(https_proxy_user="http://proxy.gov.si:80")

However I still am not able, even with the httr solution, to push/pull from github. The odd thing tho, is that I am able to do so from the shell, just not in RStudio?

The shell is just a system terminal so inherits your system's proxy configuration but it seems the Git integration on the RStudio IDE doesn't inherit the configuration. The only config option I can find about this; is for inheriting the proxy configuration from your Internet Explorer for package downloading.

Maybe you could file a feature request on the GitHub repository, for an option to define the proxy settings for the Git module from the IDE.

I have also faced this kind of connectivity restrictions in the past when working in corporate environments, the easiest solution I could found was to use a virtual server (an EC2 AWS instance) so I can set my environment to my liking without any restrictions, obviously, this will only work if your organization doesn't block AWS' IPs.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.