{"record":{"id":"489034ae718fc3f7","repo":"hashicorp/terraform","slug":"hostname-for-run-s-does-not-match-the-configure","errorCode":null,"errorMessage":"hostname for run (%s) does not match the configured cloud integration (%s)","messagePattern":"hostname for run \\((.+?)\\) does not match the configured cloud integration \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_show.go","lineNumber":28,"sourceCode":"\n\ttfe \"github.com/hashicorp/go-tfe\"\n\t\"github.com/hashicorp/terraform/internal/cloud/cloudplan\"\n\t\"github.com/hashicorp/terraform/internal/plans\"\n)\n\n// ShowPlanForRun downloads the JSON plan output for the specified cloud run\n// (either the redacted or unredacted format, per the caller's request), and\n// returns it in a cloudplan.RemotePlanJSON wrapper struct (along with various\n// metadata required by terraform show). It's intended for use by the terraform\n// show command, in order to format and display a saved cloud plan.\nfunc (b *Cloud) ShowPlanForRun(ctx context.Context, runID, runHostname string, redacted bool) (*cloudplan.RemotePlanJSON, error) {\n\tvar jsonBytes []byte\n\tmode := plans.NormalMode\n\tvar opts []plans.Quality\n\n\t// Bail early if wrong hostname\n\tif runHostname != b.Hostname {\n\t\treturn nil, fmt.Errorf(\"hostname for run (%s) does not match the configured cloud integration (%s)\", runHostname, b.Hostname)\n\t}\n\n\t// Get run and plan\n\tr, err := b.client.Runs.ReadWithOptions(ctx, runID, &tfe.RunReadOptions{Include: []tfe.RunIncludeOpt{tfe.RunPlan, tfe.RunWorkspace}})\n\tif err == tfe.ErrResourceNotFound {\n\t\treturn nil, fmt.Errorf(\"couldn't read information for cloud run %s; make sure you've run `terraform login` and that you have permission to view the run\", runID)\n\t} else if err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't read information for cloud run %s: %w\", runID, err)\n\t}\n\n\t// Sort out the run mode\n\tif r.IsDestroy {\n\t\tmode = plans.DestroyMode\n\t} else if r.RefreshOnly {\n\t\tmode = plans.RefreshOnlyMode\n\t}\n\n\t// Check that the plan actually finished","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_show.go#L10-L46","documentation":"Returned by Cloud.ShowPlanForRun when the hostname embedded in the run ID/reference (runHostname) does not equal b.Hostname, the cloud integration's configured hostname. The backend refuses to fetch a plan from a different cloud host than the one Terraform is logged into.","triggerScenarios":"Caller passes a runID/reference whose hostname (e.g. app.terraform.io) differs from the Cloud backend's configured Hostname (e.g. tfe.corp.example.com). Triggered by `terraform show`/`terraform plan` against a plan ref string scoped to another host.","commonSituations":"Multiple TFE/HCP backends in use; the cloud backend block points at one host while the plan reference was produced by another; hostname typo or trailing slash; SaaS vs self-hosted confusion.","solutions":["Align the cloud backend 'hostname' setting with the hostname of the run you are trying to view.","Re-run `terraform login` against the correct hostname whose run you want to show.","Use the fully-qualified run reference that matches the configured integration."],"exampleFix":"# before\nterraform {\n  cloud { hostname = \"app.terraform.io\" organization = \"acme\" }\n}\n# trying to show a run from tfe.corp.example.com\n# after: point the backend at the run's host\ncloud { hostname = \"tfe.corp.example.com\" organization = \"acme\" }","handlingStrategy":"validation","validationCode":"// Validate hostname match before calling ShowPlanForRun.\nif runHostname != b.Hostname {\n    return fmt.Errorf(\"refusing to show run from %s; cloud backend is %s\", runHostname, b.Hostname)\n}","typeGuard":"func sameCloudHost(configured, run string) bool {\n    return strings.EqualFold(strings.TrimRight(configured, \"/\"), strings.TrimRight(run, \"/\"))\n}","tryCatchPattern":null,"preventionTips":["Keep exactly one cloud backend hostname per project root.","Store run references with their hostname and match before display.","Normalize hostnames (strip scheme/trailing slash) when comparing."],"tags":["terraform","cloud-backend","hostname-mismatch","config","show"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}