Connect to Redis
Create a managed, Redis-compatible Valkey database in Stockholm, connect to it over TLS from your app or your machine, and choose how much of it survives a restart.
Overview
Redis in Cosmoner runs Valkey — the Linux Foundation's BSD-licensed fork of Redis 7.2, compatible with it command for command. Any Redis client library connects to it unchanged: use it for caching, sessions, rate limiting, queues and pub/sub as you would Redis.
Every database runs on Cosmoner's own hardware in Stockholm, so its data stays in Sweden. Connections are TLS-only and need a password.
Plans and prices are on Valkey & Redis Pricing.
Create a database
In your project, go to Redis and create a database. You choose:
- Plan — how much data it holds. Plans differ in dataset size, not in speed: a single instance runs commands on one thread whichever plan it is on.
- Persistence — how much of the data survives a restart. See Choosing persistence.
When it is ready, its page shows the host, port, password and a ready-made Connection string.
Connect
The connection string looks like this:
rediss://:<password>@valkey-<id>.valkey.cosmoner.com:6379Note the scheme: rediss://, with two s. TLS is required, and a client
given redis:// tries a plaintext connection that is refused.
From your app
Store the connection string as a secret — it contains
the password — and link it to your app as an environment variable, e.g.
REDIS_URL, with Link secret. Then redeploy the app so it picks the
variable up.
Node.js, with redis:
import { createClient } from "redis";
const client = createClient({ url: process.env.REDIS_URL });
client.on("error", (err) => console.error("Redis error", err));
await client.connect();
await client.set("greeting", "hej", { EX: 60 });Node.js, with ioredis:
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL);Python, with redis:
import os
import redis
r = redis.Redis.from_url(os.environ["REDIS_URL"])
r.set("greeting", "hej", ex=60)PHP, with Predis:
$client = new Predis\Client(getenv('REDIS_URL'));
$client->set('greeting', 'hej');All of these read the rediss:// scheme and turn TLS on themselves.
From your machine
The host is reachable from anywhere, so you can inspect a database with
redis-cli or a GUI client:
redis-cli --tls -u "rediss://:<password>@valkey-<id>.valkey.cosmoner.com:6379"Treat the password like any other credential: it is the only thing between the internet and your data.
Choosing persistence
Persistence is included in every plan, and the mode never changes the price.
| Mode | What can be lost on a restart | Good for |
|---|---|---|
| None | Everything — no durability is promised. | A pure cache you can rebuild. |
| Append-only file, every second | At most one second of writes. | Queues and session stores — the usual middle ground. |
| Append-only file, every write | Nothing that was acknowledged. Slowest. | Data you cannot afford to lose a write of. |
| Snapshot every hour, 6 hours or 12 hours | Writes since the last snapshot. | Data that changes slowly or can be partly rebuilt. |
When it is full
A plan's dataset size is its memory limit. When the data reaches it, Valkey makes room by evicting the least recently used keys — any key, whether or not it has an expiry. Writes keep succeeding; old data goes.
That is what you want from a cache, and a surprise anywhere else. If you keep data that must not disappear, such as a job queue, size the plan for it and watch its usage, or keep that data in a database instead.
Limits
- No high availability. A database is a single instance with no automatic failover. Plan for it being briefly unreachable during maintenance, and make your app treat a cache miss or a connection error as recoverable.
- One region: Stockholm, Sweden.
Troubleshooting
Connection refused or reset immediately. The URL uses redis://. Change it
to rediss://.
WRONGPASS or NOAUTH. The password in the URL is wrong or missing — copy
the connection string from the database's page again.
Keys disappear without expiring. The dataset reached the plan's size and the least recently used keys were evicted. Move to a larger plan, or set expiries so the data you keep is the data you use.