{"record":{"id":"2e0a61cde70ec30a","repo":"anomalyco/sst","slug":"cannot-access-nodes-cluster-in-dev-mode-2e0a61","errorCode":null,"errorMessage":"Cannot access `nodes.cluster` in dev mode.","messagePattern":"Cannot access `nodes\\.cluster` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/redis.ts","lineNumber":662,"sourceCode":"  /**\n   * The port to connect to the Redis cluster.\n   */\n  public get port() {\n    return this.dev ? this.dev.port : this.cluster!.port.apply((v) => v!);\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const _this = this;\n    return {\n      /**\n       * The ElastiCache Redis cluster.\n       */\n      get cluster() {\n        if (_this.dev)\n          throw new VisibleError(\"Cannot access `nodes.cluster` in dev mode.\");\n        return _this.cluster!;\n      },\n    };\n  }\n\n  /** @internal */\n  public getSSTLink() {\n    return {\n      properties: {\n        host: this.host,\n        port: this.port,\n        username: this.username,\n        password: this.password,\n      },\n    };\n  }\n\n  /**","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/redis.ts#L644-L680","documentation":"In SST dev mode, the Redis component does not create a real ElastiCache Redis cluster (sst dev runs the app locally without provisioning it). Accessing the `nodes.cluster` getter would return undefined, so SST throws a VisibleError telling you this node is unavailable in dev mode.","triggerScenarios":"Accessing `redis.nodes.cluster` while running `sst dev` (i.e. the `dev` flag on the component is true and the ElastiCache cluster was never created).","commonSituations":"Reading cluster properties (endpoint, ARN, security groups) in an Infra config that works in `sst deploy` but crashes during `sst dev`; referencing nodes.cluster inside shared code executed in both modes.","solutions":["Guard the access with the component's `dev` flag and use a fallback (e.g. an environment-provided local Redis URL) in dev mode","Move `nodes.cluster` access behind `if (!app.local)` / `if (!$app.local)` checks or into a `sst deploy`-only path","Use `redis.url` or the link data instead of the raw cluster node, which handles dev mode gracefully","Test the Infra change with `sst deploy --stage <stage>` instead of dev mode when you need cluster properties"],"exampleFix":"// before\nconst sg = redis.nodes.cluster.nodes.securityGroups[0];\n// after\nconst sg = redis.dev\n  ? undefined\n  : redis.nodes.cluster.nodes.securityGroups[0];","handlingStrategy":"validation","validationCode":"if (!redis.dev) {\n  const cluster = redis.nodes.cluster; // safe\n}\n// in dev, use local redis URL instead","typeGuard":"function clusterAvailable(r: { dev: boolean }): boolean {\n  return !r.dev;\n}","tryCatchPattern":"try {\n  cluster = redis.nodes.cluster;\n} catch (e) {\n  cluster = null; // fall back to local dev redis\n}","preventionTips":["Always branch on the component's `dev` flag before touching raw node properties","Prefer `redis.url`/link data over `nodes.cluster`","Run `sst dev` early to catch dev-mode-incompatible code"],"tags":["dev-mode","elasticache","redis","sst"],"backgroundTag":"resource-unavailable-in-dev-mode","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}