Skip to content
Browse docs

Connecting to Valkey on Layerbase Cloud

Valkey is Redis-compatible for common commands and clients, with a permissive open-source license.

Best for: Caching, queues, ephemeral state, rate limits, and teams replacing Redis with a BSD-licensed engine.

1

Open your database in the dashboard

Go to /cloud, click the database you just created, and the connection panel shows the host, port, username, password, and a ready-to-paste connection string for the engine.

Use the generated password and host from the Quick Connect panel.

2

TLS is required, on by default

Use rediss:// URLs or enable TLS in your Redis-compatible client.

Redis-compatible protocol over TLS on port 6379

3

Use any standard client

Valkey works with the normal client family for that engine. Start with the dashboard snippet, then move the same URL and credentials into your app environment.

If your client has separate direct, pooled, TLS, or HTTP options, prefer the exact variant shown in Quick Connect.

bashValkey
redis-cli -u "rediss://default:password@your-host.cloud.layerbase.dev:6379" ping

TLS SNI is required on port 6379

Every Redis and Valkey database on Layerbase Cloud answers on the same shared port 6379. The router picks your database from the TLS SNI hostname in the handshake, not from the port.

Node.js clients do not send an SNI hostname when you pass a bare rediss:// URL, because Node only sends SNI when the TLS servername is set explicitly. With ioredis the handshake fails with ECONNRESET ("Client network socket disconnected before secure TLS connection was established"); with node-redis it hangs, then times out. It looks like a firewall or credential problem, but it is not: set the TLS servername to your database host and it connects.

This also applies to libraries built on these clients, such as BullMQ (ioredis under the hood): pass the same tls servername through their connection options. openssl s_client and redis-cli with --sni succeed against the same endpoint because they do send SNI, which is a quick way to confirm the endpoint itself is healthy.

javascriptnode-redis
import { createClient } from 'redis'

const client = createClient({
  username: 'default',
  password: process.env.REDIS_PASSWORD,
  socket: {
    host: 'your-host.cloud.layerbase.dev',
    port: 6379,
    tls: true,
    // Required: routing on port 6379 uses the TLS SNI hostname.
    servername: 'your-host.cloud.layerbase.dev',
  },
})

await client.connect()
javascriptioredis
import Redis from 'ioredis'

// A bare rediss:// URL fails with ECONNRESET: routing on port 6379
// needs the TLS SNI hostname, and ioredis only sends it when the
// tls servername is set explicitly.
const client = new Redis(
  'rediss://default:password@your-host.cloud.layerbase.dev:6379',
  { tls: { servername: 'your-host.cloud.layerbase.dev' } },
)

Valkey notes

  • Most Redis client libraries work with Valkey without code changes.
  • If you are migrating from Redis, test module-specific commands before cutting over.