Categories
Redis

Redis Quick Fix | (error) WRONGTYPE Operation against a key holding the wrong kind of value

I recently ran into this Redis error when running the XREAD command on a Redis Stream.

This is the error I got:

(error) WRONGTYPE Operation against a key holding the wrong kind of value

This error from Redis baffled me.

After far too much time trying to figure out what went wrong, I finally realised that I had accidentally created a Redis hash with the same key as the stream I was trying to access.

What the error is saying is that we are trying to use an operation on a Redis type that doesn’t have that operation. In other words, we are trying to run a stream command on a hash or a hash command on a stream. The reason that this has happened is most likely due to having accidentally mixed up your stream and hash keys.

I explain with examples in the below video:

https://youtu.be/_ZKVf3tLGfM