charmbracelet/glow · error

unable to get url: %w

Error message

unable to get url: %w

What it means

glow fetches the parsed http/https URL with http.Get(u.String()). This error wraps the transport-level failure: DNS resolution errors, connection refused, TLS handshake failures, or unreachable proxy configured via HTTP(S)_PROXY. Bare http.Get uses the default client with no timeout, so failures here are immediate connection errors rather than timeouts.

Source

Thrown at main.go:96

	}

	// a GitHub or GitLab URL (even without the protocol):
	src, err := readmeURL(arg)
	if src != nil && err == nil {
		// if there's an error, try next methods...
		return src, nil
	}

	// HTTP(S) URLs:
	if u, err := url.ParseRequestURI(arg); err == nil && strings.Contains(arg, "://") { //nolint:nestif
		if u.Scheme != "" {
			if u.Scheme != "http" && u.Scheme != "https" {
				return nil, fmt.Errorf("%s is not a supported protocol", u.Scheme)
			}
			// consumer of the source is responsible for closing the ReadCloser.
			resp, err := http.Get(u.String()) //nolint: noctx,bodyclose
			if err != nil {
				return nil, fmt.Errorf("unable to get url: %w", err)
			}
			if resp.StatusCode != http.StatusOK {
				return nil, fmt.Errorf("HTTP status %d", resp.StatusCode)
			}
			return &source{resp.Body, u.String()}, nil
		}
	}

	// a directory:
	if len(arg) == 0 {
		// use the current working dir if no argument was supplied
		arg = "."
	}
	st, err := os.Stat(arg)
	if err == nil && st.IsDir() { //nolint:nestif
		var src *source
		_ = filepath.Walk(arg, func(path string, _ os.FileInfo, err error) error {
			if err != nil {

View on GitHub (pinned to e3970c813d)

Solutions

  1. curl -I the exact URL to reproduce the failure outside glow
  2. Check DNS and connectivity: host <hostname>
  3. Inspect HTTP_PROXY, HTTPS_PROXY and NO_PROXY values
  4. If TLS is the cause, verify the chain: openssl s_client -connect <host>:443
Defensive patterns

Strategy: retry

Validate before calling

func precheckURL(raw string) error {
	u, err := url.ParseRequestURI(raw)
	if err != nil { return err }
	if u.Scheme != "http" && u.Scheme != "https" {
		return fmt.Errorf("unsupported scheme %q", u.Scheme)
	}
	if _, err := net.LookupHost(u.Hostname()); err != nil { return err }
	return nil
}

Type guard

func isTransientNetErr(err error) bool {
	var dnsErr *net.DNSError
	if errors.As(err, &dnsErr) { return dnsErr.IsTemporary }
	var opErr *net.OpError
	return errors.As(err, &opErr)
}

Try / catch

var res *http.Response
err := retryN(3, time.Second, func() error {
	r, e := http.Get(u.String()) //nolint:noctx
	if e != nil { return e }
	res = r
	return nil
})
if err != nil { return fmt.Errorf("unable to get url: %w", err) }

Prevention

When it happens

Trigger: DNS cannot resolve the host; the server refuses the connection; TLS certificate errors (self-signed, expired) on https URLs; HTTP_PROXY/HTTPS_PROXY pointing at an unreachable proxy.

Common situations: Typos in hostnames, offline machines, corporate proxy environments with stale proxy env vars, TLS-intercepting middleboxes, firewalls blocking egress on port 443.

Related errors


AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15). Data as JSON: /api/errors/0a3cc7e76ac35211. Report an issue: GitHub.