coreybutler/nvm-windows · error

Error retrieving "%s": HTTP Status %v

Error message

Error retrieving "%s": HTTP Status %v

What it means

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.

Source

Thrown at src/web/web.go:358

	fmt.Printf("Downloading npm version " + v + "... ")
	if Download(url, fileName, v) {
		utility.DebugLog("npm download succeeded")
		fmt.Printf("Complete\n")
		return true
	} else {
		utility.DebugLog("npm download failed")
		return false
	}
}

func GetRemoteTextFile(url string) (string, error) {
	response, httperr := client.Get(url)
	if httperr != nil {
		return "", fmt.Errorf("Could not retrieve %v: %v", url, httperr)
	}

	if response.StatusCode != 200 {
		return "", fmt.Errorf("Error retrieving \"%s\": HTTP Status %v\n", url, response.StatusCode)
	}

	defer response.Body.Close()

	contents, readerr := ioutil.ReadAll(response.Body)
	if readerr != nil {
		return "", fmt.Errorf("error reading HTTP request body: %v", readerr)
	}

	return string(contents), nil
}

func IsNode64bitAvailable(v string) bool {
	if v == "latest" {
		return true
	}

	// Anything below version 8 doesn't have a 64 bit version

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. 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.
  2. Verify the mirror URL in a browser/curl: curl -I <url> must return 200.
  3. Switch to a known-good mirror (e.g. https://npmmirror.com/mirrors/node/) via nvm's mirror settings.
  4. If status is 407, configure the proxy credentials with 'nvm proxy'.

Example fix

// before
if response.StatusCode != 200 {
    return "", fmt.Errorf("Error retrieving \"%s\": HTTP Status %v\n", url, response.StatusCode)
}

// after: treat 2xx as success and drop the trailing newline from the message
if response.StatusCode < 200 || response.StatusCode > 299 {
    return "", fmt.Errorf("error retrieving %q: HTTP status %v", url, response.StatusCode)
}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check the URL returns 200 before relying on it
resp, err := http.Head(url)
if err != nil || resp.StatusCode != 200 {
    return fmt.Errorf("mirror URL %s not usable (status %v)", url, resp.StatusCode)
}

Try / catch

body, err := web.GetRemoteTextFile(url)
if err != nil && strings.Contains(err.Error(), "HTTP Status") {
    // switch mirror and retry once
    body, err = web.GetRemoteTextFile(fallbackMirror + path)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15). Data as JSON: /api/errors/47b45f6aff6e5fbd. Report an issue: GitHub.