Skip to content
PostRESP
Esc
navigateopen⌘Jpreview
On this page

Connect from your app

Point Redis clients and drivers at PostRESP — same URL shape as Redis.

PostRESP speaks Redis RESP. Any client that speaks RESP can talk to the gateway — there is no proprietary driver.

Prerequisites

Connection URL

REDIS_URL=redis://127.0.0.1:6379

If you remapped the published port (for example -p 5762:6379):

REDIS_URL=redis://127.0.0.1:5762

Redis wire auth is on by default (RequireClientAuth / REQUIRE_CLIENT_AUTH). Clients must AUTH (or use URL credentials) before other commands. The gateway verifies Postgres LOGIN roles — same identity as USERNAME / PASSWORD (default redis / redis). Set REQUIRE_CLIENT_AUTH=false for open Redis-like access (e.g. make compat). See Authentication.

Language examples

import { createClient } from "redis";

const client = createClient({
  url: process.env.REDIS_URL ?? "redis://redis:redis@127.0.0.1:6379",
});

client.on("error", (err) => console.error("Redis Client Error", err));
await client.connect();

await client.set("session:1", JSON.stringify({ user: "ada" }));
const value = await client.get("session:1");
console.log(value);

await client.quit();
import os
import redis

r = redis.from_url(os.environ.get("REDIS_URL", "redis://redis:redis@127.0.0.1:6379"))

assert r.ping() is True
r.set("session:1", '{"user":"ada"}')
print(r.get("session:1"))
import redis.clients.jedis.RedisClient;

String url = System.getenv().getOrDefault("REDIS_URL", "redis://redis:redis@127.0.0.1:6379");

try (RedisClient jedis = new RedisClient(url)) {
    jedis.set("session:1", "{\"user\":\"ada\"}");
    System.out.println(jedis.get("session:1"));
}
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;

RedisStandaloneConfiguration standalone = new RedisStandaloneConfiguration();
standalone.setHostName("127.0.0.1");
standalone.setPort(6379);
standalone.setUsername("redis");
standalone.setPassword("redis");

LettuceConnectionFactory factory = new LettuceConnectionFactory(standalone);
factory.afterPropertiesSet();

StringRedisTemplate template = new StringRedisTemplate(factory);
template.afterPropertiesSet();

template.convertAndSend("db.cache.flush.demo", "{\"type\":\"CLEAR\"}");

Pub/Sub fan-out is process-local to the RESP gateway (one hub per process). Point every app instance at the same PostRESP endpoint. HELLO 3 is refused with NOPROTO so Lettuce falls back to RESP2.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/redis/go-redis/v9"
)

func main() {
	opt, err := redis.ParseURL(envOr("REDIS_URL", "redis://127.0.0.1:6379"))
	if err != nil {
		panic(err)
	}
	rdb := redis.NewClient(opt)
	ctx := context.Background()

	if err := rdb.Set(ctx, "session:1", `{"user":"ada"}`, 0).Err(); err != nil {
		panic(err)
	}
	val, err := rdb.Get(ctx, "session:1").Result()
	if err != nil {
		panic(err)
	}
	fmt.Println(val)
}

func envOr(k, def string) string {
	if v := os.Getenv(k); v != "" {
		return v
	}
	return def
}
using StackExchange.Redis;

var url = Environment.GetEnvironmentVariable("REDIS_URL")
    ?? "redis://127.0.0.1:6379";
await using var mux = await ConnectionMultiplexer.ConnectAsync(url);
var db = mux.GetDatabase();
await db.StringSetAsync("session:1", """{"user":"ada"}""");
Console.WriteLine(await db.StringGetAsync("session:1"));
<?php
$url = getenv('REDIS_URL') ?: 'redis://127.0.0.1:6379';
$client = new Predis\Client($url);
$client->set('session:1', '{"user":"ada"}');
echo $client->get('session:1'), PHP_EOL;

Notes

  • Speak RESP2. HELLO 3 returns NOPROTO; clients should fall back.
  • SELECT only accepts database 0.
  • Protect the port with network controls as you would any Redis endpoint — Redis ACL / Sentinel / Cluster APIs are not implemented.

Was this page helpful?