I fixed this by removing the environmental variable HTTPS_PROXY that was set by another program.
Everything worked after this.