> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Redis on Square Cloud: Connection, Memory and Persistence

> Managed Redis on Square Cloud: rediss:// TLS connection, idle timeout, blocked commands, built-in modules (Search, JSON, TimeSeries), noeviction memory policy, persistence and common errors.

A managed Redis server reached over TLS, with the Search, JSON, TimeSeries, probabilistic and vector set modules built in. Facts shared by every engine (limits, snapshots, Insights) are on the [Databases overview](https://docs.squarecloud.app/en/services/databases.md).

## Connect

Copy the connection URL from the database's page in the dashboard:

```
rediss://default:PASSWORD@HOST:PORT
```

The scheme is **`rediss://`** (two s's): the server only accepts TLS, and there is no plaintext port. A client certificate is not needed; to check the server, use the `.pem` from **Connection** → **SSL/TLS certificate** as the CA. A URL saved from a database created before September 29, 2026 may still say `redis://`: change it to `rediss://`.

> [tab] node-redis
>
> ```javascript theme={"system"}
> import fs from "node:fs";
> import { createClient } from "redis";
>
> // One client for the whole process, created once and reused.
> export const redis = createClient({
>   url: process.env.REDIS_URL,
>   socket: { tls: true, ca: fs.readFileSync("certificate.pem", "utf8") },
>   pingInterval: 60_000, // keeps the connection from being closed as idle
> });
>
> redis.on("error", (err) => console.error("Redis error", err));
> await redis.connect();
> ```

> [tab] ioredis
>
> ```javascript theme={"system"}
> import fs from "node:fs";
> import Redis from "ioredis";
>
> export const redis = new Redis(process.env.REDIS_URL, {
>   tls: { ca: fs.readFileSync("certificate.pem", "utf8") },
> });
> ```

> [tab] Python
>
> ```python theme={"system"}
> import os
> import redis
>
> r = redis.from_url(
>     os.environ["REDIS_URL"],
>     ssl_ca_certs="certificate.pem",
>     health_check_interval=60,
> )
> ```

> [tab] redis-cli
>
> ```bash theme={"system"}
> redis-cli -u "rediss://default:PASSWORD@HOST:PORT" --tls --cacert certificate.pem
> ```

## Connection behavior

* **Idle clients are disconnected after 300 seconds.** Use a client that reconnects automatically (node-redis, ioredis and redis-py do) or send a periodic `PING`, as in the examples above.
* **One logical database (0).** `SELECT 1` or higher answers `ERR DB index is out of range`: separate data with key prefixes (`cache:`, `session:`) instead.
* Up to 256 simultaneous clients; past that, new ones get `max number of clients reached`. Create one client per process and reuse it.
* Authentication is the password of the `default` user. Extra ACL users can't be created.

## Commands

Every data command works, as do Lua scripts and Functions, pub/sub, `MULTI`/`EXEC`, `SCAN` and `SLOWLOG`. These are blocked and answer `NOPERM`: `FLUSHALL`, `FLUSHDB`, `SHUTDOWN`, `CONFIG`, `DEBUG`, `ACL`, `REPLICAOF`/`SLAVEOF` and `FAILOVER`.

Without `CONFIG`, the eviction policy and keyspace notifications can't be changed. To empty the database, delete keys in batches with `SCAN` and `UNLINK`:

```bash theme={"system"}
URL="rediss://default:PASSWORD@HOST:PORT"
redis-cli -u "$URL" --tls --cacert certificate.pem --scan --pattern 'cache:*' \
  | xargs -n 100 redis-cli -u "$URL" --tls --cacert certificate.pem UNLINK
```

## Built-in modules

| Module | Commands |
| :- | :- |
| Search and Query | `FT.*` (full-text, secondary indexes, vector search) |
| JSON | `JSON.*` |
| TimeSeries | `TS.*` |
| Probabilistic | `BF.*`, `CF.*`, `CMS.*`, `TOPK.*`, `TDIGEST.*` |
| Vector sets | `VADD`, `VSIM` and the other `V*` commands |

Search queries run on as many threads as the database has vCPUs.

## Memory

* Redis can hold data up to **90% of the database's RAM**. The other 10% covers its own overhead, client buffers and the room a save needs.
* The policy is **`noeviction`**: when memory is full, nothing is evicted. Writes fail with `OOM command not allowed when used memory > 'maxmemory'`, while reads keep working and the server stays up.
* So **give cache keys an expiry** (`SET key value EX 3600`, `EXPIRE`), and size the RAM for the data that has no expiry.
* Changing the database's RAM restarts it.

## Large replies

A client whose unread replies pass 32 MB (or stay above 16 MB for 60 seconds) is disconnected; for pub/sub subscribers the limits are 32 MB and 8 MB for 60 seconds. Commands that return huge replies, such as `KEYS *` or `HGETALL`/`SMEMBERS` on giant keys, and subscribers that read too slowly, get cut off. Iterate with `SCAN`, `HSCAN` and `SSCAN` instead.

## Persistence

* Redis saves its data to disk **every 60 seconds when at least one write happened**. There is no append-only file, so a crash or an out-of-memory stop loses up to the last \~60 seconds of writes. Keep data you can't lose in a database of record as well.
* If a save fails (full storage, or not enough memory to save), writes answer `MISCONF` until a save succeeds, and snapshots fail meanwhile. A save needs free storage next to the current data file, about the size of the data.

## Password reset

Resetting the password restarts Redis, which reads its password only when it starts: it is offline for a few seconds and every connection closes. Update the URL in your apps and let them reconnect.

## Snapshots

A Redis snapshot is its saved data file. Restoring one brings the data back and keeps the database's current password. See [snapshots and restore](https://docs.squarecloud.app/en/services/databases.md#snapshots-and-restore).

## Common errors

| Message | What it means | What to do |
| :- | :- | :- |
| Connection closes right away, `ECONNRESET` or a timeout | The URL uses `redis://`, without TLS. | Use `rediss://`. |
| `OOM command not allowed when used memory > 'maxmemory'` | Memory is full, and nothing is evicted. | Add expiries to cache keys, delete data or add RAM. |
| `MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk` | The last save failed. | Free storage and memory; writes resume after a save succeeds. |
| `ERR DB index is out of range` | Only database 0 exists. | Use key prefixes instead of `SELECT`. |
| `NOPERM ... has no permissions to run the '...' command` | The command is blocked. | Use `SCAN` + `UNLINK` instead of `FLUSHALL`/`FLUSHDB`. |
| `max number of clients reached` | All 256 connections are in use. | Reuse one client per process. |

## Contact us

If you continue facing **technical difficulties**, our **specialized support team** is available to assist you. [**Contact us**](https://squarecloud.app/en/support) and we'll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud [**4.9/5 across 402 reviews**](https://www.trustpilot.com/review/squarecloud.app) on Google and Trustpilot.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.