title: How to use Unix socket with node-redis?
body: <p>I have a server running both Node.js and Redis. I am using the node-redis package to connect my Node app to Redis. The Node app and Redis are both running on a single server (same server). The <a href="https://github.com/NodeRedis/node_redis#rediscreateclient" rel="nofollow noreferrer">node-redis documentation</a> at GitHub states that Redis connection throughput can be increased by using a Unix socket when using a single server configuration. What is the correct way to set up Redis/node-redis to use a Unix socket?</p>
  
  <p>I have tried uncommenting lines <code>unixsocket /var/run/redis/redis.sock</code> and <code>unixsocketperm 700</code> in the <strong>redis.conf</strong> file, and then creating the Redis client in the Node app by specifying:</p>
  
  <pre><code>let client = require('redis').createClient('/var/run/redis/redis.sock');
  </code></pre>
  
  <p>After rebooting the server I see the following error in the logs:</p>
  
  <blockquote>
    <p>Error: Redis connection to /var/run/redis/redis.sock failed - connect
    ENOENT /var/run/redis/redis.sock 0|server   |     at
    PipeConnectWrap.afterConnect [as oncomplete] (net.js:1158:14)</p>
  </blockquote>
  
  <p>I have also tried the following changes to <strong>redis.conf</strong>:</p>
  
  <p><code>#bind 127.0.0.1</code>  (commenting out the line)</p>
  
  <p><code>unixsocket /tmp/redis.sock</code>  (this is the value I see used by others; also made the corresponding change in the Node app)</p>
  
  <p><code>unixsocketperm 777</code>  (temporary relaxation of permissions to rule out permissions issues)</p>
  
  <p>None of those changes resolved the error. Note that the Node app and Redis work fine together (no errors) if I do <em>not</em> attempt to use a Unix socket. Does anyone see what I'm doing wrong?</p>