{"record":{"id":"f131eb0d0c65eba7","repo":"anomalyco/sst","slug":"cannot-access-the-url-because-no-public-ports-are","errorCode":null,"errorMessage":"Cannot access the URL because no public ports are exposed.","messagePattern":"Cannot access the URL because no public ports are exposed\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service-v1.ts","lineNumber":791,"sourceCode":"              ),\n          ),\n          command: args.dev?.command,\n        })),\n      });\n    }\n  }\n\n  /**\n   * The URL of the service.\n   *\n   * If `public.domain` is set, this is the URL with the custom domain.\n   * Otherwise, it's the auto-generated load balancer URL.\n   */\n  public get url() {\n    const errorMessage =\n      \"Cannot access the URL because no public ports are exposed.\";\n    if ($dev) {\n      if (!this.devUrl) throw new VisibleError(errorMessage);\n      return this.devUrl;\n    }\n\n    if (!this._url) throw new VisibleError(errorMessage);\n    return this._url;\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const self = this;\n    return {\n      /**\n       * The Amazon ECS Service.\n       */\n      get service() {\n        if ($dev)","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service-v1.ts#L773-L809","documentation":"The Service's `url` getter only has a value when public ports are exposed (or in dev when a dev URL exists). Accessing `.url` in `sst dev` when no dev URL was produced throws this VisibleError.","triggerScenarios":"Calling `service.url` inside `$dev` when the service has no `public` config or the dev server hasn't published a devUrl (e.g. the app didn't print/announce one).","commonSituations":"Reading `.url` in code that runs during dev mode for a private service; linking the service and reading its URL from another resource in dev.","solutions":["Configure `public` with ports so a URL exists","Guard the access with `this.devUrl` presence or wrap in try/catch","Use `sst.aws.Service`'s URL-unavailable constant pattern: check before accessing"],"exampleFix":"// before\nexport const url = service.url;\n// after\nexport const url = $dev && !service.devUrl ? undefined : service.url;","handlingStrategy":"try-catch","validationCode":"// before reading .url in dev\nif ($dev && !service.devUrl) {\n  console.log(\"no dev URL; service is not public\");\n} else {\n  const url = service.url;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const url = service.url;\n} catch (e) {\n  if (e instanceof VisibleError && e.message.includes(\"no public ports\")) {\n    const url = undefined; // handle absence\n  } else throw e;\n}","preventionTips":["Only access `.url` on services configured with public ports","Check `devUrl` before reading the URL in dev","Expose URL via stack outputs conditionally"],"tags":["url","dev-mode","public-ports"],"backgroundTag":"url-not-available","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}