Stack new faild to download the index of available snapshots

Hi, I’m trying to use stack new to set up a project with a template yesodweb/minimal. I’m using the stack version: Version 3.1.1 x86_64.

When I run stack new testing-minimal yesodweb/minimal, I get the following messages:

Downloading template yesodweb/minimal to create project testing-minimal in directory testing-minimal/...
Downloaded /HOME/.stack/templates/yesodweb/minimal.hsfiles.               
Looking for Cabal or package.yaml files to use to initialise Stack's project-level YAML configuration file.

Using the Cabal packages:
* testing-minimal/

After hanging for a bit, I get the following error message:

Error: [S-8332]
       Stack failed to create project-level YAML configuration, as it was unable to download the index of available snapshots.
       
       This sometimes happens because Certificate Authorities are missing on your system. You can try the Stack command again or manually create the configuration file. For
       help about the content of Stack's YAML configuration files, see (for the most recent release of Stack) http://docs.haskellstack.org/en/stable/yaml_configuration/.
       
       While downloading the snapshot index, Stack encountered the following error:
       
       HttpExceptionRequest Request {
         host                 = "stackage-haddock.haskell.org"
         port                 = 443
         secure               = True
         requestHeaders       = [("Accept","application/json"),("User-Agent","The Haskell Stack")]
         path                 = "/snapshots.json"
         queryString          = ""
         method               = "GET"
         proxy                = Nothing
         rawBody              = False
         redirectCount        = 10
         responseTimeout      = ResponseTimeoutDefault
         requestVersion       = HTTP/1.1
         proxySecureMode      = ProxySecureWithConnect
       }
        ConnectionTimeout

Following advice from the configuration files page for stack, I have the following lines in my .stack/config.yaml file:

urls:
  latest-snapshot: https://stackage-haddock.haskell.org/snapshots.json

But that has not fixed the problem. Does anyone have any ideas what might be behind this problem?

Can you open https://stackage-haddock.haskell.org/snapshots.json in a browser? Or does it time out as well?

It opens just fine, with no real delay.

OK. Does curl https://stackage-haddock.haskell.org/snapshots.json work in the same terminal window in which you are running stack?

Curl works just fine, and is very quick.

ping stack-haddock.haskell.org does not work, but that may just be because the server blocks ICMP requests.

I have been experiencing this same problem on my Windows 11 laptop (only, not my main Windows 11 PC) relatively recently. I’ve not yet identified the cause. My current work around is to re-boot my laptop - it then works fine (for a while).