Updated: 3 November 2026 · Applies to: Redis

To delete all keys in a Redis database, run redis-cli FLUSHDB; to delete every key across every database on the server, run redis-cli FLUSHALL. Redis calls this flushing rather than deleting. Both commands are immediate and cannot be undone, so confirm you have the right database and the right server before running either on anything that matters.

Flush the currently selected database

redis-cli FLUSHDB

This clears every key in whichever database your connection is using, database 0 by default.

Flush a specific database by number

Select the database with -n before flushing it:

redis-cli -n 5 FLUSHDB

This clears only database 5, leaving every other database on the same server untouched.

Flush every database on the server

redis-cli FLUSHALL

Unlike FLUSHDB, this is not scoped to one database; it clears all of them on that Redis server in one command.

Flush without blocking the server

Both commands are synchronous by default: on a database with a lot of keys, Redis can pause briefly while it frees all that memory, and every other client waits for it. Redis 4.0 and later support an ASYNC option that reclaims the memory in a background thread instead, so the server keeps responding to other commands while the flush completes:

redis-cli FLUSHDB ASYNC
redis-cli FLUSHALL ASYNC

Use SYNC instead of ASYNC to force the old blocking behavior explicitly, if your Redis server has lazyfree-lazy-user-flush set to make async the default and you specifically want synchronous behavior for one command.

Check what is actually in a database first

Before flushing anything, it is worth confirming you are looking at what you think you are:

redis-cli -n 5 DBSIZE

This returns the number of keys in that database, so you have a concrete count to compare against before and after.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket