micro/go-micro · error

failed request

Error message

failed request

What it means

RoundTrip in internal/util/http returns this generic error when the wrapped transport's RoundTrip fails on every retry attempt and no response could be produced. It deliberately discards the underlying per-attempt error, so callers only know that all attempts to complete the HTTP request failed.

Source

Thrown at internal/util/http/roundtripper.go:38

	}

	next := r.st(s)

	// rudimentary retry 3 times
	for i := 0; i < 3; i++ {
		n, err := next()
		if err != nil {
			continue
		}
		req.URL.Host = n.Address
		w, err := r.rt.RoundTrip(req)
		if err != nil {
			continue
		}
		return w, nil
	}

	return nil, errors.New("failed request")
}

View on GitHub (pinned to 24529f1404)

Solutions

  1. Check the target service is reachable: verify host, port, DNS, and that the service is listening (curl/telnet the endpoint).
  2. Inspect network/TLS setup — proxies, certificates, and firewall rules between client and server.
  3. Increase retry tolerance or timeouts if failures are transient, and add backoff.
  4. Wrap or modify the RoundTripper to log/join the underlying attempt errors, since this sentinel hides the root cause.

Example fix

// before
resp, err := client.Do(req) // err: "failed request" with no cause

// after
resp, err := client.Do(req)
if err != nil && err.Error() == "failed request" {
	log.Errorf("all roundtrip attempts failed for %s: underlying=%v", req.URL, lastAttemptErr)
}
Defensive patterns

Strategy: retry

Validate before calling

conn, err := net.DialTimeout("tcp", host+":"+port, 3*time.Second)
if err != nil {
	return fmt.Errorf("target %s:%s unreachable before request: %w", host, port, err)
}
conn.Close()

Try / catch

resp, err := client.Do(req)
if err != nil {
	if err.Error() == "failed request" {
		// underlying cause is hidden; retry with backoff, then alert
		return retryWithBackoff(req, 3)
	}
	return err
}

Prevention

When it happens

Trigger: An HTTP request going through this RoundTripper where each attempt's RoundTrip returns a non-nil error (connection refused, TLS handshake failure, DNS failure, timeouts) until attempts are exhausted.

Common situations: Target service down or wrong host/port; network partition between client and server; TLS certificate problems; DNS misconfiguration in containers/k8s; transient outages that outlast the retry budget.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/195474652f2dbee9. Report an issue: GitHub.