{"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":"exception","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_show.go#L10-L46","documentation":"Thrown by Cloud.ShowPlanForRun when runHostname != b.Hostname. A saved cloud plan reference encodes the hostname it was created under; the `terraform show` command refuses to fetch a plan from a different hostname than the currently configured cloud backend, to prevent cross-endpoint confusion and token misuse.","triggerScenarios":"The plan file / saved plan reference was produced against one HCP Terraform/TFE hostname (e.g. app.terraform.io) but the current backend config points at a different hostname (e.g. a self-hosted TFE at tfe.corp.local). The runHostname embedded in the plan reference does not equal b.Hostname from the current cloud config.","commonSituations":"Switching from HCP Terraform (SaaS) to self-hosted TFE while reusing a saved plan; multiple TFE instances with plan references from the wrong one; a hostname config change (custom hostname vs default) between plan and show.","solutions":["Reconfigure the cloud backend `hostname` to match the hostname in the saved plan reference (shown as the first %s).","Regenerate the plan against the currently configured hostname before running `terraform show`.","Check for trailing slashes or scheme differences in the hostname config and normalize them.","Confirm you are pointing at the correct TFE/HCP instance for this plan."],"exampleFix":"// before - plan was made on app.terraform.io, backend now points elsewhere\ncloud {\n  hostname = \"tfe.corp.local\"\n}\n// after - match the hostname embedded in the plan reference\ncloud {\n  hostname = \"app.terraform.io\"\n}","handlingStrategy":"validation","validationCode":"// Compare hostnames before calling ShowPlanForRun.\nif runHostname != b.Hostname {\n    return fmt.Errorf(\"refusing cross-hostname show: %s vs %s\", runHostname, b.Hostname)\n}","typeGuard":"func hostnamesMatch(a, b string) bool {\n    return strings.TrimRight(a, \"/\") == strings.TrimRight(b, \"/\")\n}","tryCatchPattern":null,"preventionTips":["Keep the cloud backend `hostname` stable across plan creation and `terraform show`.","Normalize hostnames (strip scheme/trailing slash) in config.","Regenerate plan references after any hostname change."],"tags":["terraform","show","hostname","cloud-plan","config-mismatch"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}