{"record":{"id":"d674747f919728bf","repo":"anomalyco/sst","slug":"cannot-access-nodes-loadbalancer-when-no-public-d67474","errorCode":null,"errorMessage":"Cannot access `nodes.loadBalancer` when no public ports are exposed.","messagePattern":"Cannot access `nodes\\.loadBalancer` when no public ports are exposed\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2912,"sourceCode":"       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if (self.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 (self.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       * The Amazon Application Auto Scaling target.\n       */\n      get autoScalingTarget() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.autoScalingTarget` in dev mode.\",\n          );\n        return self.autoScalingTarget!;\n      },\n      /**\n       * The Amazon Cloud Map service.\n       */\n      get cloudmapService() {","sourceCodeStart":2894,"sourceCodeEnd":2930,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2894-L2930","documentation":"The Service only creates an Elastic Load Balancer when public ports are exposed (e.g. via the `loadBalancer` args). When none are configured, `self.loadBalancer` is undefined and the getter throws this VisibleError rather than returning `undefined`, since the component cannot silently hand back a missing node.","triggerScenarios":"Reading `service.nodes.loadBalancer` on a Service created without a `loadBalancer`/public `ports` configuration, in deploy mode (not dev).","commonSituations":"A developer assumes every Service gets an ALB and references `nodes.loadBalancer` for a listener rule or Route53 alias, but the service was declared as internal / non-HTTP (e.g. queue worker or private gRPC service).","solutions":["Expose public ports by providing the `loadBalancer` (or `ports`) argument when creating the Service so the ALB is actually created.","If the service is intentionally private, remove the `nodes.loadBalancer` reference and wire any listener/DNS through another component.","Conditionally access the node only when your config actually sets a load balancer."],"exampleFix":"// before\nconst lb = service.nodes.loadBalancer;\n\n// after (option A: expose ports)\nconst service = new sst.aws.Service(\"Api\", {\n  cluster,\n  loadBalancer: { ports: [{ listen: \"80/http\" }] },\n});\nconst lb = service.nodes.loadBalancer;\n// or (option B: guard)\nconst lb = withLoadBalancer ? service.nodes.loadBalancer : undefined;","handlingStrategy":"validation","validationCode":"// Ensure the Service was created with a load balancer before reading the node\nconst service = new sst.aws.Service(\"Api\", {\n  cluster,\n  loadBalancer: { ports: [{ listen: \"80/http\" }] },\n});\n// only then:\nconst lb = service.nodes.loadBalancer;","typeGuard":null,"tryCatchPattern":"try {\n  const lb = service.nodes.loadBalancer;\n} catch (e) {\n  if (String(e).includes(\"no public ports\")) {\n    // service is private; use alternative routing or skip\n  } else throw e;\n}","preventionTips":["Check the Service's `loadBalancer`/ports args before referencing its load balancer node.","Track whether a service is intentionally private (workers, internal APIs) and never touch ALB nodes for those.","Centralize load-balancer wiring in one helper that validates config first."],"tags":["load-balancer","ecs","configuration","nodes"],"backgroundTag":"resource-not-created","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}