{"record":{"id":"47b45f6aff6e5fbd","repo":"coreybutler/nvm-windows","slug":"error-retrieving-s-http-status-v","errorCode":null,"errorMessage":"Error retrieving \"%s\": HTTP Status %v\n","messagePattern":"Error retrieving \"(.+?)\": HTTP Status (.+?)\n","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/web/web.go","lineNumber":358,"sourceCode":"\tfmt.Printf(\"Downloading npm version \" + v + \"... \")\n\tif Download(url, fileName, v) {\n\t\tutility.DebugLog(\"npm download succeeded\")\n\t\tfmt.Printf(\"Complete\\n\")\n\t\treturn true\n\t} else {\n\t\tutility.DebugLog(\"npm download failed\")\n\t\treturn false\n\t}\n}\n\nfunc GetRemoteTextFile(url string) (string, error) {\n\tresponse, httperr := client.Get(url)\n\tif httperr != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not retrieve %v: %v\", url, httperr)\n\t}\n\n\tif response.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"Error retrieving \\\"%s\\\": HTTP Status %v\\n\", url, response.StatusCode)\n\t}\n\n\tdefer response.Body.Close()\n\n\tcontents, readerr := ioutil.ReadAll(response.Body)\n\tif readerr != nil {\n\t\treturn \"\", fmt.Errorf(\"error reading HTTP request body: %v\", readerr)\n\t}\n\n\treturn string(contents), nil\n}\n\nfunc IsNode64bitAvailable(v string) bool {\n\tif v == \"latest\" {\n\t\treturn true\n\t}\n\n\t// Anything below version 8 doesn't have a 64 bit version","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/web/web.go#L340-L376","documentation":"GetRemoteTextFile(url) got an HTTP response, but the status code was not 200. The message embeds the URL and the actual status (403, 404, 301, 503, ...). It usually indicates a wrong/hard-coded URL, a mirror that requires different paths, or rate-limiting/CDN blocks rather than connectivity failure.","triggerScenarios":"Fetching a version index or file from a mirror whose layout differs (404), CDN blocking scripted clients (403), server-side errors (5xx), or a redirect (301/302) the client did not follow because the URL used http:// or the redirect changed scheme.","commonSituations":"Custom NVM_NODE_MIRROR/NPM_MIRROR that doesn't mirror the exact directory structure; mirrors returning 403 to non-browser user agents; transient 502/503 from heavily loaded CDNs; proxy servers returning 407 auth-required.","solutions":["Read the embedded status: 404 → the URL path is wrong for that mirror, fix the mirror setting; 403 → mirror blocks scripted access, switch mirrors; 5xx → retry later.","Verify the mirror URL in a browser/curl: curl -I <url> must return 200.","Switch to a known-good mirror (e.g. https://npmmirror.com/mirrors/node/) via nvm's mirror settings.","If status is 407, configure the proxy credentials with 'nvm proxy'."],"exampleFix":"// before\nif response.StatusCode != 200 {\n    return \"\", fmt.Errorf(\"Error retrieving \\\"%s\\\": HTTP Status %v\\n\", url, response.StatusCode)\n}\n\n// after: treat 2xx as success and drop the trailing newline from the message\nif response.StatusCode < 200 || response.StatusCode > 299 {\n    return \"\", fmt.Errorf(\"error retrieving %q: HTTP status %v\", url, response.StatusCode)\n}","handlingStrategy":"validation","validationCode":"// Pre-check the URL returns 200 before relying on it\nresp, err := http.Head(url)\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"mirror URL %s not usable (status %v)\", url, resp.StatusCode)\n}","typeGuard":null,"tryCatchPattern":"body, err := web.GetRemoteTextFile(url)\nif err != nil && strings.Contains(err.Error(), \"HTTP Status\") {\n    // switch mirror and retry once\n    body, err = web.GetRemoteTextFile(fallbackMirror + path)\n}","preventionTips":["Verify mirror URLs with curl -I — expect exactly 200.","Prefer well-known mirrors (nodejs.org, npmmirror.com/mirrors/node).","Handle proxy 407 by setting 'nvm proxy' rather than changing mirrors."],"tags":["network","http","status-code","mirror","cdn"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}