Docker now provides a custom DNS-name called host.docker.internal
for Windows/Mac versions (see https://docs.docker.com/docker-for-windows/networking/#use-cases-and-workarounds) which resolves to the internal IP address of the host.
So instead of using localhost:6379
/127.0.0.1:6379
in your connection string, change it to host.docker.internal:6379
.
Note: for Linux there's a workaround -> see https://stackoverflow.com/a/61424570/3761628