I have yii2
and yii2-redis
installed on a CraftCMS project, but when I fire up the project, I get an error message that reads:
Database Exception – yiidbException
Failed to open redis DB connection (tcp://:, database=): 0 – Failed to parse address ":"
Error Info: Failed to parse address ":"
I’m not quite sure what to do with this error. In my .env file, I put in:
REDIS_HOST=localhost
REDIS_PORT=3306
REDIS_PASSWORD=
REDIS_KEY_PREFIX=craft
But that only yielded a different error:
Database Exception – yiidbException
Failed to open redis DB connection (tcp://:3306, database=): 0 – php_network_getaddresses:
getaddrinfo failed: nodename nor servname provided, or not known
Error Info: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
Help?
Additional context: I didn’t set up the build for this project, so I more or less inherited this Redis setup.
Update:
I went and dug into the config file for the Redis setup and found a misnaming between the .env variables and what was present in the .env file. Now I’m getting a completely different error:
"Received illegal data from redis: Redis command was: SELECT 0"
2
Answers
Turns out I'd deleted the Redis database (don't remember how or when), so creating a new one (with the correct .env variables set) fixed the problem immediately.
Whew.
Please check that your configuration matches the environment variables you use.