{"record":{"id":"8bf5c8e5f31bc4fe","repo":"hashicorp/terraform","slug":"organization-q-at-host-s-not-found-please-ensu","errorCode":null,"errorMessage":"organization %q at host %s not found.\n\nPlease ensure that the organization and hostname are correct and that your API token for %s is valid.","messagePattern":"organization %q at host (.+?) not found\\.\n\nPlease ensure that the organization and hostname are correct and that your API token for (.+?) is valid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend.go","lineNumber":361,"sourceCode":"\t// Create the remote backend API client.\n\tb.client, err = tfe.NewClient(cfg)\n\tif err != nil {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Failed to create the Terraform Enterprise client\",\n\t\t\tfmt.Sprintf(\n\t\t\t\t`The \"remote\" backend encountered an unexpected error while creating the `+\n\t\t\t\t\t`Terraform Enterprise client: %s.`, err,\n\t\t\t),\n\t\t))\n\t\treturn diags\n\t}\n\n\t// Check if the organization exists by reading its entitlements.\n\tentitlements, err := b.client.Organizations.ReadEntitlements(context.Background(), b.organization)\n\tif err != nil {\n\t\tif err == tfe.ErrResourceNotFound {\n\t\t\terr = fmt.Errorf(\"organization %q at host %s not found.\\n\\n\"+\n\t\t\t\t\"Please ensure that the organization and hostname are correct \"+\n\t\t\t\t\"and that your API token for %s is valid.\",\n\t\t\t\tb.organization, b.hostname, b.hostname)\n\t\t}\n\t\tdiags = diags.Append(tfdiags.AttributeValue(\n\t\t\ttfdiags.Error,\n\t\t\tfmt.Sprintf(\"Failed to read organization %q at host %s\", b.organization, b.hostname),\n\t\t\tfmt.Sprintf(\"The \\\"remote\\\" backend encountered an unexpected error while reading the \"+\n\t\t\t\t\"organization settings: %s\", err),\n\t\t\tcty.Path{cty.GetAttrStep{Name: \"organization\"}},\n\t\t))\n\t\treturn diags\n\t}\n\n\t// Configure a local backend for when we need to run operations locally.\n\tb.local = backendLocal.NewWithBackend(b)\n\tb.forceLocal = b.forceLocal || !entitlements.Operations\n","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend.go#L343-L379","documentation":"Returned by Remote.Configure when the TFE Organizations.ReadEntitlements call fails with tfe.ErrResourceNotFound, meaning the configured organization does not exist at the given hostname (or the token cannot see it). The message is user-facing and instructs verifying both the organization name and the API token validity.","triggerScenarios":"Configure() runs after service discovery + token retrieval, then calls Organizations.ReadEntitlements(b.organization); a 404 response maps to ErrResourceNotFound and is rewritten into this guidance message.","commonSituations":"Typo in the 'organization' attribute; organization renamed/deleted on Terraform Cloud/Enterprise; API token belongs to a different org or lacks access; token expired or revoked; wrong hostname (pointing at an instance without that org).","solutions":["Verify the 'organization' attribute exactly matches the TFC/TFE org name (case-sensitive).","Confirm the token is for the same hostname and has access to that org: curl -H \"Authorization: Bearer <token>\" https://<host>/api/v2/organizations.","If the org was renamed, update the backend block.","Re-run 'terraform login <hostname>' if the token may have expired."],"exampleFix":"# before\nterraform {\n  backend \"remote\" {\n    hostname     = \"app.terraform.io\"\n    organization = \"MyOrg\"   # wrong case / renamed\n  }\n}\n# after\nterraform {\n  backend \"remote\" {\n    hostname     = \"app.terraform.io\"\n    organization = \"my-org\"  # exact slug\n  }\n}","handlingStrategy":"validation","validationCode":"// Pre-flight: verify the org is reachable with the configured token\nimport \"github.com/hashicorp/go-tfe\"\n\nfunc orgAccessible(ctx context.Context, host, token, org string) error {\n  c, err := tfe.NewClient(&tfe.Config{Address: \"https://\"+host, Token: token})\n  if err != nil { return err }\n  if _, err := c.Organizations.Read(ctx, org); err != nil {\n    return fmt.Errorf(\"org %q unreachable on %s with this token: %w\", org, host, err)\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"// Configure surfaces this via tfdiags; in custom code, branch on ErrResourceNotFound\ndiags := b.Configure(obj)\nfor _, d := range diags {\n    if strings.Contains(d.Description().Summary, \"not found\") {\n        // prompt for correct org name or re-login\n    }\n}","preventionTips":["Validate the organization slug and token with a Read call before Configure.","Re-run 'terraform login <hostname>' when tokens may have expired.","Lock the org name in a shared variable to avoid typos.","Confirm the token's scope covers the target org in TFC/TFE UI."],"tags":["terraform-remote-backend","authentication","configuration","tfc","tfe"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}