I have some information stored in my RedisToGo instance in Heroku and I want to wipe it so the Redis store is clean. Any idea how to do this?
-
Yes I want to clear the entire store. – kidcapital Feb 04 '12 at 03:11
12 Answers
You can do this with redis-cli.
RedisToGo gives you a url in the form:
redis://redistogo:d20739cffb0c0a6fff719acc2728c236@catfish.redistogo.com:9402
So this command will empty your db:
redis-cli -h catfish.redistogo.com -p 9402 -a d20739cffb0c0a6fff719acc2728c236 flushall

- 10,924
- 9
- 52
- 71
-
1
-
1
-
This no longer works. You get a NOAUTH error. There may be a missing step, but the steps above will just yield an error. – Jesse Farmer Sep 21 '18 at 04:18
-
@JesseFarmer I was just able to run this command successfully. Received "OK" response. You might want to double check your credentials. – ty. Sep 22 '18 at 08:11
-
@ty, it responds with OK, but it seems like it doesn't actually clear it. So far I wasn't able to find a way to clear rediscloud redis without accessing rails console. – AndreiMotinga Sep 29 '18 at 18:47
-
For anyone reading this answer, you can simply do `redis-cli -u redis://...` with the URL – Tallboy May 08 '22 at 02:54
You can install the heroku-redis-cli plugin
Installation
Requirements:
The heroku gem —
gem install heroku
A local installation of redis (or at least the redis-cli utility) —
apt-get install redis-server
To install:
heroku plugins:install https://github.com/rapportive-oss/heroku-redis-cli.git
Usage
heroku redis:info
— get run-time statistics from your redis.heroku redis:monitor
— monitor commands being sent to your redis in real time.heroku redis:cli
— execute custom commands against redis.
Then you could simply do:
$ heroku redis:cli
$ flushall
Steps taken from readme file on the github repo: https://github.com/rapportive-oss/heroku-redis-cli

- 1,634
- 15
- 17
-
4It is not an _Heroku_ command but an [heroku-redis-cli](https://github.com/rapportive-oss/heroku-redis-cli) plugin command. – esbanarango Apr 14 '14 at 20:02
-
5
-
1
-
To wipe your redis on heroku there are a couple of ways. One of the simplest is probably connecting to the heroku console and clearing it from there. Commands are (for cedar stack):
heroku run console
REDIS.flushall
And that's it :-)

- 393
- 3
- 2
You can do this with the heroku console:
$ heroku redis:cli -a my_app --confirm my_app
$ FLUSHALL

- 1,442
- 2
- 20
- 40
You can destroy and recreate the entire Redis datastore for your app by doing:
heroku addons:remove redistogo
heroku addons:add redistogo

- 29,283
- 9
- 49
- 85
-
1Is there a better way than dropping and re-adding the whole instance? – kidcapital Feb 04 '12 at 03:11
-
1That's the easiest way. If you are using the environment variable then this should be a quick and easy change. – James Ward Feb 04 '12 at 03:23
In order to empty the store, you can run the flushall command: http://redis.io/commands/flushall
So, simply something like:
$redis.flushall
if you're doing it with Ruby or similar.

- 22,105
- 18
- 80
- 134
-
2It depends on what you're using to be honest, if it's something like Rails you can run it via the Rails console (`heroku run console`) - however, it's very dependant on what tools you're using. – Neil Middleton Feb 05 '12 at 13:36
Get a python shell on heroku by doing the following CLI:
heroku run python
Then in that shell type
import os
import redis
redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost')
r = redis.from_url(redis_url)
r.flushdb()

- 3,788
- 7
- 43
- 54

- 957
- 8
- 10
I'm using Ruby on Rails on Heroku and tried this, it worked (After heroku run rails console
)
> $redis = Redis.new url: ENV['REDISCLOUD_URL']
> $redis.flushall
=> "OK"

- 5,252
- 3
- 34
- 36
This can be done in one convenient one-liner, even for non-ruby apps:
echo " FLUSHALL\r\n QUIT" | heroku redis:cli -a MY_APP --confirm MY_APP
Replace MY_APP
with the name of your app.
Note: This assumes that you have Heroku CLI installed.

- 958
- 12
- 14
You can use this https://github.com/rapportive-oss/heroku-redis-cli to connect to the Redis instance you are using, Heroku update broke it some time ago but there is a fix https://github.com/johnbeynon/heroku-redis-cli. Then just do flushdb

- 1,225
- 12
- 12
If you're looking for a one-liner (and happen to be using Rails), you can do
heroku run rails runner 'REDIS.flushall'
rather than connecting first (with console) then manually entering the flushall
command.

- 4,424
- 1
- 19
- 26