{"record":{"id":"54eadba896782c29","repo":"anomalyco/sst","slug":"cannot-configure-health-check-for-k-make-sur","errorCode":null,"errorMessage":"Cannot configure health check for \"${k}\". Make sure it is defined in \"loadBalancer.ports\".","messagePattern":"Cannot configure health check for \"(.+?)\"\\. Make sure it is defined in \"loadBalancer\\.ports\"\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2082,"sourceCode":"      );\n\n      // normalize public/private\n      const pub = output(inlineLoadBalancer).apply((lb) =>\n        \"public\" in lb ? lb.public ?? true : true,\n      );\n\n      // normalize health check\n      const health = all([type, rules, inlineLoadBalancer]).apply(\n        ([type, rules, lb]) =>\n          Object.fromEntries(\n            Object.entries((\"health\" in lb ? lb.health : {}) ?? {}).map(\n              ([k, v]) => {\n                if (\n                  !rules.find(\n                    (r) => `${r.forwardPort}/${r.forwardProtocol}` === k,\n                  )\n                )\n                  throw new VisibleError(\n                    `Cannot configure health check for \"${k}\". Make sure it is defined in \"loadBalancer.ports\".`,\n                  );\n                const protocol = k.split(\"/\")[1];\n                return [\n                  k,\n                  {\n                    path: [\"http\", \"https\"].includes(protocol)\n                      ? v.path ?? \"/\"\n                      : undefined,\n                    interval: v.interval ? toSeconds(v.interval) : 30,\n                    timeout: v.timeout\n                      ? toSeconds(v.timeout)\n                      : type === \"application\"\n                        ? 5\n                        : 6,\n                    healthyThreshold: v.healthyThreshold ?? 5,\n                    unhealthyThreshold: v.unhealthyThreshold ?? 2,\n                    protocol: [\"http\", \"https\"].includes(protocol)","sourceCodeStart":2064,"sourceCodeEnd":2100,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2064-L2100","documentation":"Health checks in SST's Service load balancer are keyed by \"port/protocol\" and every key must correspond to a forward target defined in loadBalancer.ports (derived from the rules). A health check entry referencing an unknown \"port/protocol\" string means it would never attach to a real target group.","triggerScenarios":"Setting loadBalancer.health with a key like \"8080/http\" when ports only define \"80/http\", or a typo such as \"80/htpp\" or \"3000\" without the protocol suffix.","commonSituations":"Renaming container ports without updating health check keys; copying health config from another service on different ports; forgetting health keys use forwardPort/forwardProtocol, not the listen port.","solutions":["Change the health key to exactly match a forward target, e.g. \"80/http\"","Add the corresponding port to loadBalancer.ports if the container really exposes it","Fix typos in port or protocol segment of the key"],"exampleFix":"// before\nports: { \"80/http\": \"app:3000\" }, health: { \"3000/http\": \"/healthz\" }\n// after\nports: { \"80/http\": \"app:3000\" }, health: { \"80/http\": \"/healthz\" }","handlingStrategy":"validation","validationCode":"const forwardKeys = new Set(config.loadBalancer.rules.map(r => {\n  const [lp, lproto] = r.listen.split(\"/\");\n  const [fp, fproto] = r.forward ? r.forward.split(\"/\") : [lp, lproto];\n  return `${fp}/${fproto}`;\n}));\nfor (const k of Object.keys(config.loadBalancer.health ?? {}))\n  if (!forwardKeys.has(k)) throw new Error(`health key \"${k}\" not in ports`);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Derive health keys from the same constants used for ports","Remember health keys use the forward port/protocol, not the listen port","Keep port and health definitions adjacent in config to spot drift"],"tags":["load-balancer","health-check","validation"],"backgroundTag":"health-check-config-mismatch","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}