thanos-io/thanos · error

creating request to downstream URL

Error message

creating request to downstream URL

What it means

Inside the readiness actor, Thanos builds a GET request to <downstream-url>/-/ready using http.NewRequestWithContext and wraps construction failures with this message. http.NewRequest only errors on malformed URLs or invalid method/context, so this indicates the downstream URL could not be turned into a valid request.

Solutions

  1. Fix --query-frontend.downstream-url to a well-formed absolute URL with scheme (http:// or https://).
  2. Manually curl <downstream-url>/-/ready to confirm the URL is usable.
  3. Check shell quoting/interpolation that may inject spaces or variables into the flag value.
  4. Read the wrapped parse error to see the rejected URL exactly.

Example fix

// before
--query-frontend.downstream-url=http://query-frontend :9090
// after
--query-frontend.downstream-url=http://query-frontend:9090
Defensive patterns

Strategy: try-catch

Validate before calling

u, err := url.Parse(downstreamURL + "/-/ready")
if err != nil || u.Scheme == "" || u.Host == "" {
  return fmt.Errorf("ready probe url invalid: %q", downstreamURL)
}

Try / catch

req, err := http.NewRequestWithContext(ctx, http.MethodGet, readyURL, nil)
if err != nil {
  return fmt.Errorf("creating request to downstream URL: %w", err)
}

Prevention

When it happens

Trigger: cfg.DownstreamURL malformed (bad scheme, invalid characters, empty) such that appending '/-/ready' yields a URL http.NewRequestWithContext rejects; invalid context.

Common situations: Downstream URL configured without scheme, containing spaces or invalid characters, or misquoted in a shell so the flag receives garbage.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/940edc08ddd021a2. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/query_frontend.go:416

			srv.Shutdown(err)
		})
	}

	// Periodically check downstream URL to ensure it is reachable.
	{
		ctx, cancel := context.WithCancel(context.Background())

		g.Add(func() error {
			var firstRun = true

			doCheckDownstream := func() (rerr error) {
				timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
				defer cancel()

				readinessUrl := cfg.DownstreamURL + "/-/ready"
				req, err := http.NewRequestWithContext(timeoutCtx, http.MethodGet, readinessUrl, nil)
				if err != nil {
					return errors.Wrap(err, "creating request to downstream URL")
				}

				resp, err := downstreamRT.RoundTrip(req)
				if err != nil {
					return errors.Wrapf(err, "roundtripping to downstream URL %s", readinessUrl)
				}
				defer runutil.CloseWithErrCapture(&rerr, resp.Body, "downstream health check response body")

				if resp.StatusCode/100 == 4 || resp.StatusCode/100 == 5 {
					return errors.Errorf("downstream URL %s returned an error: %d", readinessUrl, resp.StatusCode)
				}

				return nil
			}
			for {
				if !firstRun {
					select {
					case <-ctx.Done():

View on GitHub (pinned to 35b8b99117)