<p>I used 2 pods and service on my Kubernetes cluster. They are Redis and my nodeJs application. Also I used scaffold for dev environment.</p>
<p>I want to connect Redis from my nodeJs application. I set environment variable on my nodeJs_app.yaml file for connection to Redis.</p>
<p>My nodeJs_app.yaml file look like:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodeJsApp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: no
  template:
    metadata:
      labels:
        app: nodeJsApp
    spec:
      containers:
        - name: nodeJsApp
          image: nodeJsApp
          env:
            - name:  REDISCONNECTIONDEV
              value: &quot;redis://redis-srv:6379/&quot;
---
apiVersion: v1
kind: Service
metadata:
  name: nodeJsApp
spec:
  type: NodePort
  selector:
    app: nodeJsApp
  ports:
    - name: nodeJsApp
      protocol: TCP
      port: 3000
      nodePort: 30001
</code></pre>
<p>Also my Redis.yaml file like that:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - name: redis
          image: redis
---
apiVersion: v1
kind: Service
metadata:
  name: redis-srv
spec:
  selector:
    app: redis
  ports:
    - name: redis
      protocol: TCP
      port: 6379
      targetPort: 6379
</code></pre>
<p>I checked with <strong>kubectl get pods</strong> and <strong>kubectl get services</strong> and each services and ports running correctly.</p>
<p>On my NodeJs_app/index.js file I tried to connect Redis service with:</p>
<pre><code>let REDIS_URL = process.env.REDISCONNECTIONDEV || production_redis_url;
let redisQueue = new Queue('my queue', REDIS_URL);

redisQueue('global:completed', (jobId, result) =&gt; {
    // console.log(`Job completed with result ${result}`);
});
</code></pre>
<p>But this situation return an error like that:</p>
<pre><code>/app/node_modules/redis-parser/lib/parser.js:179
     return new ReplyError(string)
            ^
 
ReplyError: ERR value is not an integer or out of range
     at parseError (/app/node_modules/redis-parser/lib/parser.js:179:12)
     at parseType (/app/node_modules/redis-parser/lib/parser.js:302:14) {
   command: { name: 'select', args: [ 'NaN' ] }
 }
</code></pre>
<p>Also I'm new to Redis. Why this problem is occuring? How can I solve this?</p>

<p>Error occurs because you are trying to connect to redis database with NaN instead of number (number indicates database, 1-16). Check your code, because in some place you put NaN instead of number while trying to connect to redis database.</p>
<p><a href="https://stackoverflow.com/questions/35621324/how-to-create-own-database-in-redis">How to create own database in redis?</a></p>
