title: Using go with redis - not able to connect
body: <p>I'm trying to connect to Redis service in azure</p>
  
  <p>I use the following code:</p>
  
  <pre><code>    import (
          "fmt"
          "os"
          "github.com/go-redis/redis"
      )
  
  
  func main() {
       uri := os.Getenv("uri")
       fmt.Println("uri is", uri)
       opt, err := redis.ParseURL(uri)
       if err != nil {
           fmt.Println(err)
        }
       fmt.Println("addr is:”, opt.Addr)
       fmt.Println("db is:”, opt.DB)
       fmt.Println("password is:”, opt.Password)
       //connect to redis
       client = redis.NewClient(opt)
       //Here I want to get connection
       pong, err := client.Ping().Result()
  </code></pre>
  
  <p><a href="https://github.com/go-redis/redis" rel="nofollow noreferrer">https://github.com/go-redis/redis</a></p>
  
  <p><a href="https://godoc.org/github.com/go-redis/redis#example-ParseURL" rel="nofollow noreferrer">https://godoc.org/github.com/go-redis/redis#example-ParseURL</a></p>
  
  <p><strong>The printed data is like following</strong> I was able to the the connection string</p>
  
  <pre><code>uri is rediss://:bBMfQ7wFdkPHr8u%2B2zzNOzUpy85OEjYv7KbPZd8B89M%3D@e49ab3c6-8f72-416a-a6c1-ddfe75gf200e.redis.cache.windows.net:6380
  
  
  addr is: e49ab3c6-8f72-416a-a6c1-ddfe75gf200e.redis.cache.windows.net:6380
  db is: 0
  password is: bBMfQ7wFdkPHr8u+2zzNOzUpy85OEjYv7KbPZd8B89M=
  </code></pre>
  
  <p>The Redis service is up and running and I was able to connect with <code>nodejs</code> application and <strong>get the data</strong>, any idea why I got the error in go: </p>
  
  <p><strong>dial tcp 40.128.8.87:6380: connect: connection refused</strong></p>
  
  <p>We are trying to migrate some apps from Nodejs to go ...</p>
  
  <p><strong>The strange thing</strong> is that in <strong>nodejs</strong> I use the following which works!</p>
  
  <p><a href="https://github.com/NodeRedis/node-redis" rel="nofollow noreferrer">https://github.com/NodeRedis/node-redis</a></p>
  
  <pre><code>const redisClient = redis.createClient(process.env.uri);
  
  redisClient.on("connect", () =&gt; console.log("Redis is connected"));
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>I've provisioned a new instance <strong>without ssl</strong> which is not working either</p>
  
  <p><strong>This is the logs</strong> </p>
  
  <pre><code>uri is redis://:TKq1n%2BO29jsSdIkoysXL%2Btwd6Xi0IO0KNxw%3D@2dca2dx1-20e0-48ca-83ed-20bf52e99b97.redis.cache.windows.net:6379
  addr is 2dca2dx1-20e0-48ca-83ed-20bf52e99b97.redis.cache.windows.net:6379
  db is 0
  password is TKq1n+O29jsSdIkoysXL+twd6Xi0IO0KNxw=
   dial tcp 40.113.7.3:6379: connect: connection refused
  </code></pre>
  
  <p>Any idea how should I use the GO api to connect to redis properly ? </p>
  
  <p>Btw, when I connected to <strong>local</strong> Redis it works, but not to azure cache</p>
  
  <p>like this</p>
  
  <pre><code>client := redis.NewClient(&amp;redis.Options{
          Addr: "localhost:6379",
          Password: "",
          DB: 0,
      })
  </code></pre>
  
  <p>Maybe I miss something in the Redis api, as I do the same (connect to the same service instance )  for nodejs and it works!</p>