{
  "schema_version": 2,
  "id": "operate/rs/references/cli-utilities/redis-cli",
  "title": "redis-cli",
  "url": "https://redis.io/docs/latest/operate/rs/references/cli-utilities/redis-cli/",
  "summary": "Run Redis commands.",
  "tags": [
    "docs",
    "operate",
    "rs",
    "rc"
  ],
  "last_updated": "2026-09-24T14:53:09+01:00",
  "children": [],
  "page_type": "content",
  "content_hash": "8e5e677d9fe80346ae8096c558dc501ee8aedbec74156b41d83de923847a8fc7",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "The `redis-cli` command-line utility lets you interact with a Redis database. With `redis-cli`, you can run [Redis commands](/content/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](https://redis.io/docs/latest/develop/tools/insight) and use the built-in [CLI](https://redis.io/docs/latest/develop/tools/insight) prompt instead."
    },
    {
      "id": "install-redis-cli",
      "title": "Install `redis-cli`",
      "role": "setup",
      "text": "When you install Redis 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](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack)\n\n- [Redis Software](https://redis.io/docs/latest/operate/rs/installing-upgrading/quickstarts/redis-enterprise-software-quickstart)\n\n- [Redis Software with Docker](https://redis.io/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart)\n\nIf you only need `redis-cli` on your local machine to connect to a remote database, you can [install the standalone `redis-cli` binary](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/install-redis-cli) on Linux or macOS, without installing the full Redis Open Source distribution."
    },
    {
      "id": "connect-to-a-database",
      "title": "Connect to a database",
      "role": "content",
      "text": "To 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."
    },
    {
      "id": "connect-remotely",
      "title": "Connect remotely",
      "role": "content",
      "text": "If 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[code example]\n\nYou can also provide the password with the `REDISCLI_AUTH` environment variable instead of the `-a` option:\n\n[code example]"
    },
    {
      "id": "connect-over-tls",
      "title": "Connect over TLS",
      "role": "content",
      "text": "To connect to a Redis Software or Redis Cloud database over TLS:\n\n1. Download or copy the Redis Software server (or proxy) certificates.\n\n    - For Redis Cloud, see [Download certificates](https://redis.io/docs/latest/operate/rc/security/database-security/tls-ssl#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 Software, copy the proxy certificate from the Cluster Manager UI (**Cluster > Security > Certificates > 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 Software server certificate (`redis_ca.pem` for Cloud or `proxy_cert.pem` for Software) when you connect:\n\n    [code example]\n\n1. If your database requires client authentication, provide your client's private and public keys along with the Redis Software server certificate (`redis_ca.pem` for Cloud or `proxy_cert.pem` for Software) when you connect:\n\n    [code example]"
    },
    {
      "id": "connect-with-docker",
      "title": "Connect with Docker",
      "role": "content",
      "text": "If your Redis database runs in a Docker container, you can use `docker exec` to run `redis-cli` commands:\n\n[code example]"
    },
    {
      "id": "basic-use",
      "title": "Basic use",
      "role": "content",
      "text": "You can run `redis-cli` commands directly from the command-line terminal:\n\n[code example]\n\nFor example, you can use `redis-cli` to test your database connection and store a new Redis string in the database:\n\n[code example]\n\nFor more information, see [Command line usage](https://redis.io/docs/latest/develop/tools/cli#command-line-usage)."
    },
    {
      "id": "interactive-mode",
      "title": "Interactive mode",
      "role": "content",
      "text": "In `redis-cli` [interactive mode](https://redis.io/docs/latest/develop/tools/cli#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](https://redis.io/docs/latest/develop/tools/cli#preferences).\n- Enter [`HELP`](https://redis.io/docs/latest/develop/tools/cli#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[code example]"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": ""
    },
    {
      "id": "check-slowlog",
      "title": "Check slowlog",
      "role": "content",
      "text": "Run [`slowlog get`](https://redis.io/docs/latest/commands/slowlog-get) for a list of recent slow commands:\n\n[code example]"
    },
    {
      "id": "scan-for-big-keys",
      "title": "Scan for big keys",
      "role": "content",
      "text": "Scan the database for big keys:\n\n[code example]\n\nSee [Scanning for big keys](https://redis.io/docs/latest/develop/tools/cli#scanning-for-big-keys) for more information."
    },
    {
      "id": "more-info",
      "title": "More info",
      "role": "content",
      "text": "- [Redis CLI documentation](https://redis.io/docs/latest/develop/tools/cli)\n- [Redis commands reference](/content/commands)"
    }
  ],
  "examples": [
    {
      "id": "connect-remotely-ex0",
      "language": "sh",
      "code": "$ redis-cli -h <endpoint> -p <port> -a <password>",
      "section_id": "connect-remotely"
    },
    {
      "id": "connect-remotely-ex1",
      "language": "sh",
      "code": "$ export REDISCLI_AUTH=<password>\n$ redis-cli -h <endpoint> -p <port>",
      "section_id": "connect-remotely"
    },
    {
      "id": "connect-over-tls-ex0",
      "language": "sh",
      "code": "redis-cli -h <endpoint> -p <port> --tls --cacert <redis_cert>.pem",
      "section_id": "connect-over-tls"
    },
    {
      "id": "connect-over-tls-ex1",
      "language": "sh",
      "code": "redis-cli -h <endpoint> -p <port> --tls --cacert <redis_cert>.pem \\\n        --cert redis_user.crt --key redis_user_private.key",
      "section_id": "connect-over-tls"
    },
    {
      "id": "connect-with-docker-ex0",
      "language": "sh",
      "code": "$ docker exec -it <Redis container name> redis-cli -p <port>",
      "section_id": "connect-with-docker"
    },
    {
      "id": "basic-use-ex0",
      "language": "sh",
      "code": "$ redis-cli -h <endpoint> -p <port> <Redis command>",
      "section_id": "basic-use"
    },
    {
      "id": "basic-use-ex1",
      "language": "sh",
      "code": "$ redis-cli -h <endpoint> -p 12000 PING\nPONG\n$ redis-cli -h <endpoint> -p 12000 SET mykey \"Hello world\"\nOK\n$ redis-cli -h <endpoint> -p 12000 GET mykey              \n\"Hello world\"",
      "section_id": "basic-use"
    },
    {
      "id": "interactive-mode-ex0",
      "language": "sh",
      "code": "$ redis-cli -p 12000\n127.0.0.1:12000> PING\nPONG\n127.0.0.1:12000> SET mykey \"Hello world\"\nOK\n127.0.0.1:12000> GET mykey\n\"Hello world\"",
      "section_id": "interactive-mode"
    },
    {
      "id": "check-slowlog-ex0",
      "language": "sh",
      "code": "redis-cli -h <endpoint> -p <port> slowlog get <number of entries>",
      "section_id": "check-slowlog"
    },
    {
      "id": "scan-for-big-keys-ex0",
      "language": "sh",
      "code": "redis-cli -h <endpoint> -p <port> --bigkeys",
      "section_id": "scan-for-big-keys"
    }
  ]
}
