Docker Community Forums

Share and learn in the Docker community.

Issue running Redis with Docker in Windows 10 pro - can't connect to redis at localhost

I have just setup redis using docker in windows and I am trying to write a simple .Net console app to connect to it to familiarize myself with things.

I am running docker in windows 10 pro using “docker run redis:windowsservercore”

The redis instance looks like it boots up fine and will display:

[1904] 21 Mar 13:18:50.835 # Server started, Redis version 3.2.100

[1904] 21 Mar 13:18:50.847 - The server is now ready to accept connections on port 6379

But in my app when I try to connect to localhost:6379 it seems as if it can’t find the redis instance at all:

var log = new StringWriter();
StackExchange.Redis.ConnectionMultiplexer RedisConnection = StackExchange.Redis.ConnectionMultiplexer.Connect(“localhost:6379”, log); // This line errors
var cache = RedisConnection.GetDatabase(1);
cache.StringSet(“Test”, “Hello World”);
catch (Exception ex) { }
The connection above always fails with:

“It was not possible to connect to the redis server(s). UnableToConnect on localhost:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 2s ago, last-write: 2s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 9s ago, v:”

I just can’t figure out what I am doing wrong here. I have tried connecting using other naming methods for localhost. I disabled all firewalls for public and private networks to ensure this wasn’t the issue.

I am note sure what I need to do here to get a connection established, hopefully someone has some advice for me.

Thanks everyone in advance

Hi :slight_smile:

In your docker run command: “docker run redis:windowsservercore”, you need to define which port should be available for others to access the service.

so your command should look like: docker run -p 6379:6379 redis:windowsservercore

i got same issue again after running redis using same command you gave

it is solved?
i am facing same issue , but could not find an anwser

Hi all,

First of all, I wish people would stop posting that this is a port issue, trust me I saw this all over the internet for every single example when researching the issue before coming here, and I definitely tried setting the port directly and it did not resolve the issue.

To resolve this I followed the step by step directions found on the redis website and ultimately I had to set this up as a Linux container.

Follow the above guide line by line and hopefully you can get your issue resolved.

Cheers ~

I am getting the same issue, I just want to test my application in docker with Redis pubsub,

but not able to do it,

I have post issue in

can you help me with it?