glanceapp/glance · error

could not solve reddit challenge

Error message

could not solve reddit challenge

What it means

Returned at update time by the reddit widget when fetching the anonymous 'loid' cookie (Reddit's device-ID challenge cookie) fails. Before requesting subreddit JSON, Glance calls getRedditLoidCookie; any error there is swallowed into a log line and replaced with this generic message, so the underlying cause (network, DNS, proxy, or Reddit blocking) is hidden.

Source

Thrown at internal/glance/widget-reddit.go:225

		requestURL = fmt.Sprintf("%s/r/%s/%s.json?%s", baseURL, widget.Subreddit, widget.SortBy, query.Encode())
	}

	if widget.RequestURLTemplate != "" {
		requestURL = strings.ReplaceAll(widget.RequestURLTemplate, "{REQUEST-URL}", requestURL)
	} else if widget.Proxy.client != nil {
		client = widget.Proxy.client
	}

	request, err := http.NewRequest("GET", requestURL, nil)
	if err != nil {
		return nil, err
	}
	request.Header = headers

	loid, err := getRedditLoidCookie()
	if err != nil {
		fmt.Printf("Error fetching reddit loid cookie: %v\n", err)
		return nil, errors.New("could not solve reddit challenge")
	}
	request.AddCookie(&http.Cookie{Name: "loid", Value: loid})

	responseJson, err := decodeJsonFromRequest[subredditResponseJson](client, request)
	if err != nil {
		return nil, err
	}

	if len(responseJson.Data.Children) == 0 {
		return nil, fmt.Errorf("no posts found")
	}

	posts := make(forumPostList, 0, len(responseJson.Data.Children))

	for i := range responseJson.Data.Children {
		post := &responseJson.Data.Children[i].Data

		if post.Stickied || post.Pinned {

View on GitHub (pinned to 91324e8de7)

Solutions

  1. From the Glance host, verify plain reachability of reddit.com (curl -I https://www.reddit.com) and fix DNS/proxy/firewall if it fails
  2. Set the widget's proxy field (or global proxy env vars) so the Reddit traffic egresses from a non-blocked IP
  3. Configure app-auth (name/id/secret) to use authenticated OAuth access instead of the anonymous loid flow
  4. If Reddit is rate-limiting, increase cache duration or reduce the number of reddit widgets to lower request frequency

Example fix

# before
- type: reddit
  subreddit: selfhosted

# after (authenticated app access bypasses the loid challenge)
- type: reddit
  subreddit: selfhosted
  app-auth:
    name: my-glance-app
    id: abc123
    secret: xyz789
Defensive patterns

Strategy: retry

Validate before calling

import urllib.request
try:
    urllib.request.urlopen('https://www.reddit.com', timeout=10)
    print('reddit reachable')
except Exception as e:
    print('reddit NOT reachable from this host:', e)

Try / catch

if err != nil && strings.Contains(err.Error(), "could not solve reddit challenge") {
    // transient: widget already shows an error state and the next update cycle retries;
    // if persistent, check egress, set proxy, or switch to app-auth instead of retry-looping
    slog.Warn("reddit challenge failed; will retry next update", "error", err)
}

Prevention

When it happens

Trigger: Reddit's loid endpoint being unreachable from the Glance host; DNS failure for reddit.com; an egress proxy/firewall blocking the cookie request; Reddit rate-limiting or geo-blocking the server's IP; the anonymous challenge flow changing on Reddit's side.

Common situations: Self-hosted servers in datacenter IP ranges that Reddit challenges or blocks; Docker containers with broken DNS; corporate proxies stripping cookies; Reddit outages or API changes after a site redesign.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/26152cced5882e2d. Report an issue: GitHub.