{"record":{"id":"25feee23e02df3f1","repo":"hashicorp/terraform","slug":"http-remote-state-internal-server-error","errorCode":null,"errorMessage":"HTTP remote state internal server error","messagePattern":"HTTP remote state internal server error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/backend/remote-state/http/client.go","lineNumber":166,"sourceCode":"\tif err != nil {\n\t\treturn nil, diags.Append(err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// Handle the common status codes\n\tswitch resp.StatusCode {\n\tcase http.StatusOK:\n\t\t// Handled after\n\tcase http.StatusNoContent:\n\t\treturn nil, diags\n\tcase http.StatusNotFound:\n\t\treturn nil, diags\n\tcase http.StatusUnauthorized:\n\t\treturn nil, diags.Append(fmt.Errorf(\"HTTP remote state endpoint requires auth\"))\n\tcase http.StatusForbidden:\n\t\treturn nil, diags.Append(fmt.Errorf(\"HTTP remote state endpoint invalid auth\"))\n\tcase http.StatusInternalServerError:\n\t\treturn nil, diags.Append(fmt.Errorf(\"HTTP remote state internal server error\"))\n\tdefault:\n\t\treturn nil, diags.Append(fmt.Errorf(\"Unexpected HTTP response code %d\", resp.StatusCode))\n\t}\n\n\t// Read in the body\n\tbuf := bytes.NewBuffer(nil)\n\tif _, err := io.Copy(buf, resp.Body); err != nil {\n\t\treturn nil, diags.Append(fmt.Errorf(\"Failed to read remote state: %s\", err))\n\t}\n\n\t// Create the payload\n\tpayload := &remote.Payload{\n\t\tData: buf.Bytes(),\n\t}\n\n\t// If there was no data, then return nil\n\tif len(payload.Data) == 0 {\n\t\treturn nil, diags","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/http/client.go#L148-L184","documentation":"During Get(), the state server returned 500 Internal Server Error. The backend treats this as a hard failure (not retried here because the retryablehttp client only retries on connection errors and a configurable set of status codes by default; 500 surfaces immediately). It means the state endpoint itself is broken — server-side exception, upstream store down, or application bug.","triggerScenarios":"State server bug processing the GET; backing storage (S3/database) unreachable from the state server; reverse proxy returning 500 because the upstream crashed. Fires at state read time.","commonSituations":"State server misconfigured or out of disk/memory; backing store outage; deployment of a broken state server build; schema migration mid-flight.","solutions":["Check the state server's logs for the exception behind the 500.","Confirm backing storage connectivity from the state server host.","Retry once the server team confirms recovery; raise retry_max/retry_wait_max only if the server is known to be flaky.","If persistent, fall back to a known-good state snapshot and engage the state server maintainers."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isServer500(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"HTTP remote state internal server error\")\n}","tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n  err = runTerraform()\n  if err == nil { break }\n  if isServer500(err) && attempt < 2 { backoff(); continue }\n  return err\n}","preventionTips":["Monitor the state server's health and surface 500s to its owners.","Keep recent state snapshots for fallback.","Engage the state server maintainers before retrying into a known-broken endpoint."],"tags":["http","server-error","http-backend","terraform"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}