{"record":{"id":"7820ea2a7e6dcb58","repo":"portainer/portainer","slug":"cannot-use-localhost-as-environment-url","errorCode":null,"errorMessage":"cannot use localhost as environment URL","messagePattern":"cannot use localhost as environment URL","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"api/internal/edge/url.go","lineNumber":27,"sourceCode":"\n// ParseHostForEdge returns the hostname of the given URL, will fail if host is localhost\nfunc ParseHostForEdge(portainerURL string) (string, error) {\n\tparsedURL, err := url.Parse(portainerURL)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Unable to parse Portainer URL\")\n\t}\n\n\tportainerHost, _, err := net.SplitHostPort(parsedURL.Host)\n\tif err != nil {\n\t\tportainerHost = parsedURL.Host\n\t}\n\n\tif portainerHost == \"\" {\n\t\treturn \"\", errors.New(\"hostname cannot be empty\")\n\t}\n\n\tif portainerHost == \"localhost\" {\n\t\treturn \"\", errors.New(\"cannot use localhost as environment URL\")\n\t}\n\n\treturn portainerHost, nil\n\n}\n","sourceCodeStart":9,"sourceCodeEnd":33,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/internal/edge/url.go#L9-L33","documentation":"Error \"cannot use localhost as environment URL\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/internal/edge/url.go:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}