{"record":{"id":"95c4eca8feff72c3","repo":"anomalyco/sst","slug":"cannot-access-nodes-loadbalancer-in-dev-mode","errorCode":null,"errorMessage":"Cannot access `nodes.loadBalancer` in dev mode.","messagePattern":"Cannot access `nodes\\.loadBalancer` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service-v1.ts","lineNumber":834,"sourceCode":"      get taskRole() {\n        return self.taskRole;\n      },\n      /**\n       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if ($dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.taskDefinition` in dev mode.\",\n          );\n        return self.taskDefinition!;\n      },\n      /**\n       * The Amazon Elastic Load Balancer.\n       */\n      get loadBalancer() {\n        if ($dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` in dev mode.\",\n          );\n        if (!self.loadBalancer)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` when no public ports are exposed.\",\n          );\n        return self.loadBalancer;\n      },\n    };\n  }\n\n  /** @internal */\n  public getSSTLink() {\n    return {\n      properties: { url: $dev ? this.devUrl : this._url },\n    };\n  }\n}","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service-v1.ts#L816-L852","documentation":"The `nodes.loadBalancer` getter on the v1 `Service` component returns the ALB resource created when public ports are exposed. In `sst dev` mode no load balancer is provisioned, so accessing the getter throws this `VisibleError` before the more specific 'no public ports' check can run.","triggerScenarios":"Accessing `service.nodes.loadBalancer` during `sst dev`, regardless of whether public ports are configured.","commonSituations":"Adding listeners/rules to the ALB or referencing the ALB DNS name in other components from code that also runs in dev mode.","solutions":["Wrap the access in `if (!$dev)`.","Use `service.url` in dev mode to get the dev endpoint instead of the ALB DNS name.","Configure routing via the `loadBalancer` prop (rules/ports) rather than mutating `nodes.loadBalancer` post-hoc."],"exampleFix":"// before\nconst dns = svc.nodes.loadBalancer.loadBalancer.dnsName;\n\n// after\nif (!$dev) {\n  const dns = svc.nodes.loadBalancer.loadBalancer.dnsName;\n}","handlingStrategy":"validation","validationCode":"if (!$dev) {\n  const lb = myService.nodes.loadBalancer;\n}","typeGuard":"const hasLoadBalancerInDev = (): boolean => !($dev as boolean);","tryCatchPattern":"try {\n  return myService.nodes.loadBalancer;\n} catch (e) {\n  if (e instanceof VisibleError && e.message.includes(\"loadBalancer\")) return null;\n  throw e;\n}","preventionTips":["In dev, use `service.url` instead of the ALB DNS name.","Configure routing declaratively via `loadBalancer` props instead of mutating nodes.","Keep dev-only and deploy-only code in separate branches guarded by `$dev`."],"tags":["aws","ecs","alb","dev-mode","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"}