Skip to main content

Testing a Redis connection

The gateway talks to Redis for two different jobs. The response cache stores model answers so repeated prompts are served without a provider call, and the coordination Redis shares rate limit counters, spend tracking and scheduled job locks between gateway replicas. Both are configured from the Response Cache page or over the API, and both have a test route that tries the connection with the values you typed without saving anything or touching the running gateway. A third route, GET /cache/ping, checks the cache the gateway is using right now. All three are part of the free gateway.

A real-world scenario​

An operator is moving the gateway from a shared Redis to a dedicated Valkey cluster. Before changing anything in production she pastes the new URL into the Cache Settings tab and clicks Test Connection. The test fails with a certificate error, so she turns on SSL, tests again and gets a success. Only then does she click Save Changes, and the gateway starts caching on the new cluster without a restart. She repeats the test on the Coordination Redis tab, saves, and schedules the restart that the coordination settings need.

Step by step​

In the Admin UI​

  1. Open /ui/caching as a proxy admin and pick the Cache Settings tab.
  2. Choose the Redis Type, Node (Single Instance), Cluster, Sentinel or Semantic, and fill in Connection Settings. A Redis URL takes precedence over Host, Port, Password and Database Index. Secret fields that already have a value read Already set. Enter a new value to replace it. and keep the saved secret when left empty.
  3. Click Test Connection. The button reads Testing... while the gateway connects. A success shows Cache connection test successful! and a failure shows Connection test failed with the reason.
  4. Click Save Changes once the test passes. The gateway saves the settings, starts the cache on them at once and shows Cache settings updated successfully.
  5. Pick the Cache Health tab and click Run Health Check to confirm the running cache. Summary shows Cache Status with a green check, the cache type under Cache Configuration, Ping Response and Set Cache Response, and for Redis the Redis Host, Redis Port, Redis Version, Startup Nodes and Namespace.
  6. For the coordination Redis pick the Coordination Redis tab, fill in the same kind of connection settings, click Test Connection and then Save Changes. The tab says Saved changes take effect on proxy restart., so restart the gateway afterwards.

With curl​

Test response cache settings without saving them.

curl -X POST http://localhost:4000/cache/settings/test \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"cache_settings": {"type": "redis", "host": "redis.internal", "port": "6379", "password": "***REDACTED***"}}'

A credential sent as ***REDACTED*** falls back to the saved one, so a form that left the password untouched still tests with the real password. Only type: redis can be tested, and that covers cluster, sentinel and semantic Redis configurations through their own fields such as redis_startup_nodes and sentinel_nodes.

Save the settings once the test passes, then check the running cache.

curl -X POST http://localhost:4000/cache/settings \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"cache_settings": {"type": "redis", "host": "redis.internal", "port": "6379", "password": "s3cret", "namespace": "prod", "ttl": 600}}'

curl http://localhost:4000/cache/ping -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

Test and save the coordination Redis.

curl -X POST http://localhost:4000/coordination_redis/settings/test \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"settings": {"host": "redis-coordination.internal", "port": 6379, "password": "s3cret", "ssl": true}}'

curl -X POST http://localhost:4000/coordination_redis/settings \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"settings": {"host": "redis-coordination.internal", "port": 6379, "password": "s3cret", "ssl": true}}'

Values such as os.environ/COORDINATION_REDIS_PASSWORD are stored as written and resolved when the gateway starts.

Expected result​

A passing cache test answers 200 with a success status. The verdict always comes back as 200, so read status rather than the HTTP code.

{"status": "success", "message": "Redis connection test successful", "error": null}

A failed test looks like {"status": "failed", "message": "Cache connection test failed: Error 111 connecting to redis.internal:6379. Connection refused.", "error": "..."}.

Saving answers with the saved settings, credentials redacted, and the gateway caches on them from the next request.

{"message": "Cache settings updated successfully", "status": "success", "settings": {"type": "redis", "host": "redis.internal", "port": "6379", "password": "***REDACTED***", "namespace": "prod", "ttl": 600}}

GET /cache/ping on a healthy Redis cache answers with "status": "healthy", "ping_response": true and "set_cache_response": "success", plus the masked cache parameters the Cache Health tab lists. The coordination test answers {"status": "healthy", "error": null} or {"status": "unhealthy", "error": "Connection timed out after 5.0s"}, and the coordination save answers Coordination Redis settings updated successfully. Restart the proxy to apply them. Every save writes an audit log row with the settings before and after, credentials redacted.

Errors​

What you seeWhyFix
status: failed with Connection refusedThe host or port is wrong, or a firewall blocks the gateway.Check the address from the gateway host, not your laptop.
status: failed with AUTH or WRONGPASS in the messageThe password or username is wrong, or you sent ***REDACTED*** with nothing saved yet.Type the real password.
status: failed with a certificate or SSL messageThe server requires TLS, or presents a certificate the gateway does not trust.Turn on SSL, and set SSL Cert Reqs or SSL Check Hostname to match the server.
status: failed, Only Redis cache type is currently supported for testingtype was not redis.Set "type": "redis". Other backends are tested by saving and running the health check.
status: unhealthy, Connection timed out after 5.0s on the coordination testThe coordination Redis did not answer within five seconds.Check the address, security groups and whether the server is up.
500 Database not connected or Set STORE_MODEL_IN_DB=True on saveSaved settings live in the database.Connect a database, set STORE_MODEL_IN_DB=True and restart. Tests still work without it.
503 from GET /cache/ping with Cache not initializedNo response cache is configured.Save cache settings or set cache: true with cache_params in the config file.
401 Authentication Error, Only proxy admin can be used to ... on save or testThe key is not a proxy admin or admin viewer key.Use a proxy admin key.
403 user not allowed to access this route, role= proxy_admin_viewer. ... on save or testAdmin viewers can read settings and run the health check only.Use a proxy admin key.
Failed to load cache settings in the Admin UIThe settings row could not be read or decrypted.Check the gateway log for the error and that the salt key used to encrypt the row has not changed.

Logs​

LevelLineMeaning and action
INFOCache settings initialized from databaseA replica loaded the saved cache settings at startup or after a save on another replica. Normal.
WARNINGCLIENT LIST command failed (likely restricted on managed Redis): ...A managed Redis refuses the client list, so Redis info reports -1 clients. Normal on managed services.
WARNINGFailed to write cache-settings audit log: ...The save worked but its audit row was not written. Check the database.
ERRORError testing cache connection: ...Test Connection failed. The answer carries the same reason.
ERRORError updating cache settings: ... or Error fetching cache settings: ...Saving or reading the settings row failed, often the database or the salt key.
ERRORCache health check failed with a stack trace/cache/ping could not reach the cache. Check the connection settings.