'InternetOpenUrl failed: 'A connection with the server could not be established'

I have gone down a rabbit hole trying to set up Github actions to check the builds of my packages via usethis::use_github_action_check_standard(). The function fails when it tries to pull the .yaml file from the r-lib repo. I am stuck trying to figure out why readLines() fails for me. It appears that readLines() fails for any files from Github, but does work for files from other locations.

##
## random .txt file works
##
readLines("https://filesamples.com/samples/document/txt/sample1.txt")
#> Warning in readLines("https://filesamples.com/samples/document/txt/
#> sample1.txt"): incomplete final line found on 'https://filesamples.com/samples/
#> document/txt/sample1.txt'
#> [1] "Utilitatis causa amicitia est quaesita."                                                                                                                                                                                                                                                                                                                   
#> [2] "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Collatio igitur ista te nihil iuvat. Honesta oratio, Socratica, Platonis etiam. Primum in nostrane potestate est, quid meminerimus? Duo Reges: constructio interrete. Quid, si etiam iucunda memoria est praeteritorum malorum? Si quidem, inquit, tollerem, sed relinquo. An nisi populari fama?"
#> [3] ""                                                                                                                                                                                                                                                                                                                                                          
#> [4] "Quamquam id quidem licebit iis existimare, qui legerint. Summum a vobis bonum voluptas dicitur. At hoc in eo M. Refert tamen, quo modo. Quid sequatur, quid repugnet, vident. Iam id ipsum absurdum, maximum malum neglegi."
#
##
## random .yaml file also works (very long, not showing output)
## 
# readLines("https://wg21.link/index.yaml")

##
## .yaml file from github does not work
##
readLines("https://raw.githubusercontent.com/r-lib/actions/master/examples/check-standard.yaml", encoding = "UTF-8")
#> Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server
#> could not be established'
#> Error in file(con, "r"): cannot open the connection

##
## .txt file from github does not work
##
readLines("https://raw.githubusercontent.com/neslib/Neslib.Yaml/master/License.txt")
#> Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server
#> could not be established'
#> Error in file(con, "r"): cannot open the connection

I have tried checking and unchecking Use Internet Explorer library/proxy for HTTP in the RStudio options to no effect.

Created on 2021-08-05 by the reprex package (v2.0.0)



Solution 1:[1]

For anyone else who might hit this problem - I lost the Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server could not be established' warnings after enabling TLS 1.2:

  • Control Panel > Internet Options > Advanced tab
  • Scroll to Security category, manually check the option box for Use TLS 1.2

Found this solution after getting the same set of errors (as in the question) when using download.file(), where the default method for Windows is wininet.dll

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1