Solution for: data in redis cannot be accessed after the python redis module is connected

created at 07-24-2021 views: 6

Problem background

Use redis to restore the data of dump.rdb successfully, use redis-cli test to see if the data is restored successfully, the results are as follows:

redis-cli>KYES *

1) "a"
2) "b"
3) "c"
4) "d"
5) "e"

Use the redis module to access the redis data and find that none of the data can be obtained. The relevant code is as follows:

import redis
conn = redis.Redis() 
print conn.keys()


Use the command netstat -tunlp to get redis information in linux, and find that the redis process is different from the normal process.

0  *               LISTEN      3845/redis-server *

# Normal process
:::6379  *               LISTEN      3845/redis-server *


Modify the redis connection method

import redis
conn = redis.Redis(host='', port=6379) 
print conn.keys()

created at:07-24-2021
edited at: 07-24-2021: