{
  "id": "redis-cli",
  "title": "redis-cli",
  "url": "https://redis.io/docs/latest/operate/rs/7.8/references/cli-utilities/redis-cli/",
  "summary": "Run Redis commands.",
  "content": "\nThe `redis-cli` command-line utility lets you interact with a Redis database. With `redis-cli`, you can run [Redis commands]() directly from the command-line terminal or with [interactive mode](#interactive-mode).\n\nIf you want to run Redis commands without `redis-cli`, you can [connect to a database with Redis Insight]() and use the built-in [CLI]() prompt instead.\n\n## Install `redis-cli`\n\nWhen you install Redis Enterprise Software or Redis Open Source, it also installs the `redis-cli` command-line utility.\n\nTo learn how to install Redis and `redis-cli`, see the following installation guides:\n\n- [Redis Open Source]()\n\n- [Redis Enterprise Software]()\n\n- [Redis Enterprise Software with Docker]()\n\n## Connect to a database\n\nTo run Redis commands with `redis-cli`, you need to connect to your Redis database.\n\nYou can find endpoint and port details in the **Databases** list or the database’s **Configuration** screen.\n\n### Connect remotely\n\nIf you have `redis-cli` installed on your local machine, you can use it to connect to a remote Redis database. You will need to provide the database's connection details, such as the hostname or IP address, port, and password.\n\n```sh\n$ redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e -a \u003cpassword\u003e\n```\n\nYou can also provide the password with the `REDISCLI_AUTH` environment variable instead of the `-a` option:\n\n```sh\n$ export REDISCLI_AUTH=\u003cpassword\u003e\n$ redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e\n```\n\n### Connect over TLS\n\nTo connect to a Redis Enterprise Software or Redis Cloud database over TLS:\n\n1. Download or copy the Redis Enterprise server (or proxy) certificates.\n\n    - For Redis Cloud, see [Download certificates]() for detailed instructions on how to download the server certificates (`redis_ca.pem`) from the [Redis Cloud console](https://cloud.redis.io/).\n\n    - For Redis Enterprise Software, copy the proxy certificate from the Cluster Manager UI (**Cluster \u003e Security \u003e Certificates \u003e Server authentication**) or from a cluster node (`/etc/opt/redislabs/proxy_cert.pem`).\n\n1. Copy the certificate to each client machine.\n\n1. If your database doesn't require client authentication, provide the Redis Enterprise server certificate (`redis_ca.pem` for Cloud or `proxy_cert.pem` for Software) when you connect:\n\n    ```sh\n    redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e --tls --cacert \u003credis_cert\u003e.pem\n    ```\n\n1. If your database requires client authentication, provide your client's private and public keys along with the Redis Enterprise server certificate (`redis_ca.pem` for Cloud or `proxy_cert.pem` for Software) when you connect:\n\n    ```sh\n    redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e --tls --cacert \u003credis_cert\u003e.pem \\\n        --cert redis_user.crt --key redis_user_private.key\n    ```\n\n### Connect with Docker\n\nIf your Redis database runs in a Docker container, you can use `docker exec` to run `redis-cli` commands:\n\n```sh\n$ docker exec -it \u003cRedis container name\u003e redis-cli -p \u003cport\u003e\n```\n\n## Basic use\n\nYou can run `redis-cli` commands directly from the command-line terminal:\n\n```sh\n$ redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e \u003cRedis command\u003e\n```\n\nFor example, you can use `redis-cli` to test your database connection and store a new Redis string in the database:\n\n```sh\n$ redis-cli -h \u003cendpoint\u003e -p 12000 PING\nPONG\n$ redis-cli -h \u003cendpoint\u003e -p 12000 SET mykey \"Hello world\"\nOK\n$ redis-cli -h \u003cendpoint\u003e -p 12000 GET mykey              \n\"Hello world\"\n```\n\nFor more information, see [Command line usage](#command-line-usage).\n\n## Interactive mode\n\nIn `redis-cli` [interactive mode](#interactive-mode), you can:\n\n- Run any `redis-cli` command without prefacing it with `redis-cli`.\n- Enter `?` for more information about how to use the `HELP` command and [set `redis-cli` preferences](#preferences).\n- Enter [`HELP`](#showing-help-about-redis-commands) followed by the name of a command for more information about the command and its options.\n- Press the `Tab` key for command completion.\n- Enter `exit` or `quit` or press `Control+D` to exit interactive mode and return to the terminal prompt.\n\nThis example shows how to start interactive mode and run Redis commands:\n\n```sh\n$ redis-cli -p 12000\n127.0.0.1:12000\u003e PING\nPONG\n127.0.0.1:12000\u003e SET mykey \"Hello world\"\nOK\n127.0.0.1:12000\u003e GET mykey\n\"Hello world\"\n```\n\n## Examples\n\n### Check slowlog\n\nRun [`slowlog get`]() for a list of recent slow commands:\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e slowlog get \u003cnumber of entries\u003e\n```\n\n### Scan for big keys\n\nScan the database for big keys:\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e --bigkeys\n```\n\nSee [Scanning for big keys](#scanning-for-big-keys) for more information.\n\n## More info\n\n- [Redis CLI documentation]()\n- [Redis commands reference]()\n",
  "tags": ["docs","operate","rs","rc"],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "children": []
}

