xtekky/gpt4free · error

download failed: HTTP %s

Error message

download failed: HTTP %s

What it means

downloadRuntime in g4f-go/download.go checks resp.StatusCode after a successful GET and errors with 'download failed: HTTP %s' for anything other than 200. This is a server-side response: the URL was reached but returned an error status (404 not found, 403 forbidden, 5xx, or a 3xx the client did not follow).

Source

Thrown at g4f-go/download.go:119

	out, err := os.Create(partName(binDir))
	if err != nil {
		return err
	}
	// Network http.Client with no default timeout: progress is what keeps the
	// user informed, not a hard cutoff.
	client := &http.Client{}
	resp, err := client.Get(spec.URL)
	if err != nil {
		out.Close()
		os.Remove(partName(binDir))
		return fmt.Errorf("download failed: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		out.Close()
		os.Remove(partName(binDir))
		return fmt.Errorf("download failed: HTTP %s", resp.Status)
	}

	// Prefer Content-Length; fall back to manifest size.
	total := resp.ContentLength
	if total <= 0 {
		total = spec.Size
	}
	_, copyErr := copyWithProgress(out, resp.Body, total, start)
	if cerr := out.Close(); copyErr == nil {
		copyErr = cerr
	}
	if copyErr != nil {
		os.Remove(partName(binDir))
		return fmt.Errorf("download interrupted: %w", copyErr)
	}
	if err := os.Rename(partName(binDir), cachePath); err != nil {
		os.Remove(partName(binDir))
		return err

View on GitHub (pinned to 973504e177)

Solutions

  1. curl -I the exact spec.URL to confirm the status code
  2. Update runtime.json (and the binary embedding it) to a release whose runtime asset still exists
  3. For 403: check whether the host blocks unauthenticated or regional requests; use a mirror if provided
  4. For 5xx: retry later once the hosting service recovers

Example fix

# before
# runtime: download failed: HTTP 404 Not Found

# after
curl -I "https://host/runtime-linux-x64.tar.gz"   # confirm 404
# edit runtime.json -> point platforms.linux-x64.url at the current asset
# rebuild/refresh the g4f-go binary so it embeds the fixed manifest
Defensive patterns

Strategy: try-catch

Validate before calling

resp, err := http.Head(spec.URL)
if err == nil && resp.StatusCode != http.StatusOK {
    // stale/blocked asset: fix runtime.json before attempting the download
}

Try / catch

err := downloadRuntime(binDir, cachePath, spec)
if err != nil && strings.Contains(err.Error(), "download failed: HTTP") {
    // refresh the manifest URL / use a mirror, then retry once
}

Prevention

When it happens

Trigger: spec.URL in runtime.json points to a moved/deleted artifact (404), the CDN requires auth or blocks your region/IP (403), the server is failing (5xx), or a redirect chain ends in an error because the client follows redirects to a signed URL that expired.

Common situations: Stale runtime.json referencing a released-then-deleted asset; expired pre-signed S3 URLs; CDN geo-blocking; GitHub asset links after a release was yanked.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/e11445f3f93dbffc. Report an issue: GitHub.