argoproj/argo-workflows · error

request failed with: %w

Error message

request failed with: %w

What it means

The artifact download HTTP request made by getAndStoreArtifactData failed at the transport level: c.Do(request) returned an error before a response was received. This covers DNS failure, connection refused/reset, TLS handshake errors, and context cancellation — not HTTP error statuses (those produce 'request failed %s').

Source

Thrown at cmd/argo/commands/cp.go:137

	if err != nil {
		return nil, err
	}
	return &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, nil
}

func getAndStoreArtifactData(ctx context.Context, namespace string, workflowName string, nodeID string, artifactName string, fileName string, customPath string, c *http.Client, argoServerOpts apiclient.ArgoServerOpts) error {
	request, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/artifacts/%s/%s/%s/%s", argoServerOpts.GetURL(), namespace, workflowName, nodeID, artifactName), nil)
	if err != nil {
		return fmt.Errorf("failed to create request: %w", err)
	}
	authString, err := client.GetAuthString(ctx)
	if err != nil {
		return err
	}
	request.Header.Set("Authorization", authString)
	resp, err := c.Do(request)
	if err != nil {
		return fmt.Errorf("request failed with: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("request failed %s", resp.Status)
	}
	artifactFilePath := filepath.Join(customPath, fileName)
	fileWriter, err := os.Create(artifactFilePath)
	if err != nil {
		return fmt.Errorf("creating file failed: %w", err)
	}
	defer fileWriter.Close()
	_, err = io.Copy(fileWriter, resp.Body)
	if err != nil {
		return fmt.Errorf("copying file contents failed: %w", err)
	}
	log.Printf("Created %q", fileName)
	return nil
}

View on GitHub (pinned to 35bff19146)

Solutions

  1. Confirm the server URL and that argo-server is up: `kubectl -n argo get pods`, `curl -k https://<host>:2746/`.
  2. Set up the local port-forward or correct ARGO_SERVER/ARGO_HTTP1 env values.
  3. If the error is x509/TLS, configure the CA cert or ARGO_INSECURE_SKIP_VERIFY=true for dev only.
  4. If context cancelled, re-run with a longer deadline and don't interrupt the command mid-download.

Example fix

// before (connection refused — nothing listening)
argo cp my-wf ./out
// after
kubectl -n argo port-forward svc/argo-server 2746:2746 &
argo cp my-wf ./out
Defensive patterns

Strategy: retry

Validate before calling

# pre-flight connectivity check
curl -sk --max-time 5 "${ARGO_SCHEME:-https}://${ARGO_SERVER:-localhost:2746}/" >/dev/null || { echo "argo server unreachable"; exit 1; }

Try / catch

// retry with backoff; surface TLS vs connection errors distinctly
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
  time.Sleep(time.Second); return retry()
}
if strings.Contains(err.Error(), "x509") {
  return fmt.Errorf("TLS verification failed; configure CA cert or ARGO_INSECURE_SKIP_VERIFY")
}

Prevention

When it happens

Trigger: The argo server is not reachable at argoServerOpts.GetURL(): server down, wrong host/port, no port-forward, DNS failure, TLS certificate verification failure, or the context was cancelled (Ctrl-C / deadline) mid-request.

Common situations: Forgetting `kubectl -n argo port-forward svc/argo-server 2746:2746` locally; argo-server pod not running; self-signed certs without CA config (x509 errors); corporate proxy/VPN blocking; firewall between CI and the cluster.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/8802a6383477d7eb. Report an issue: GitHub.