jackwener/OpenCLI · error

HTTP ' + res.status + ' - make sure you are logged in to Ins

Error message

HTTP ' + res.status + ' - make sure you are logged in to Instagram

What it means

Thrown in clis/instagram/search.js when the topsearch user-lookup request to Instagram returns a non-OK status. The request relies on 'credentials: include' and the X-IG-App-ID header, so failures indicate the browser/session context is not authenticated or Instagram refused the request.

Source

Thrown at clis/instagram/search.js:25

    domain: 'www.instagram.com',
    args: [
        { name: 'query', required: true, positional: true, help: 'Search query' },
        { name: 'limit', type: 'int', default: 10, help: 'Number of results' },
    ],
    columns: ['rank', 'username', 'name', 'verified', 'private', 'url'],
    pipeline: [
        { navigate: 'https://www.instagram.com' },
        { evaluate: `(async () => {
  const query = \${{ args.query | json }};
  const limit = \${{ args.limit }};
  const res = await fetch(
    'https://www.instagram.com/web/search/topsearch/?query=' + encodeURIComponent(query) + '&context=user',
    {
      credentials: 'include',
      headers: { 'X-IG-App-ID': '936619743392459' }
    }
  );
  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
  const data = await res.json();
  const users = (data?.users || []).slice(0, limit);
  return users.map((item, i) => ({
    rank: i + 1,
    username: item.user?.username || '',
    name: item.user?.full_name || '',
    verified: item.user?.is_verified ? 'Yes' : 'No',
    private: item.user?.is_private ? 'Yes' : 'No',
    url: 'https://www.instagram.com/' + (item.user?.username || ''),
  }));
})()
` },
    ],
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate and ensure the fetch runs in a context where Instagram cookies are included (credentials: 'include' with a valid session)
  2. Check res.status: 401/403 means login problem, 429 means slow down
  3. Verify the X-IG-App-ID value is still accepted by Instagram (it rotates occasionally)
  4. Retry with a simpler query to rule out query-specific blocking

Example fix

// before
if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
// after
if (!res.ok) {
  const body = await res.text().catch(() => '');
  throw new Error(`Instagram search failed: HTTP ${res.status} ${body.slice(0, 200)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!query || !query.trim()) throw new Error('Search query is required');
// ensure fetch runs inside an authenticated page context with cookies

Type guard

function hasUsers(data) { return Array.isArray(data?.users) && data.users.length > 0; }

Try / catch

try {
  const results = await searchUsers(query, limit);
} catch (e) {
  if (/HTTP 40[13]/.test(e.message)) throw new Error('Re-login required: ' + e.message);
  if (/HTTP 429/.test(e.message)) throw new Error('Rate limited; retry later');
  throw e;
}

Prevention

When it happens

Trigger: res.ok is false after `fetch('https://www.instagram.com/web/search/topsearch/?query=...&context=user', { credentials: 'include', headers: { 'X-IG-App-ID': '936619743392459' } })` — typically 302-to-login, 401, 403, or 429 responses.

Common situations: Session cookie expired or not sent (e.g. running outside the authenticated browser context), Instagram changing the web endpoint or rejecting the hardcoded app ID, or query rate-limiting.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/e65be6b7b25cfb3a. Report an issue: GitHub.