jackwener/OpenCLI · error · 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
The instagram explore command's in-page script calls Instagram's web explore_grid API with cookie credentials; if the response is not ok, it throws a plain Error 'HTTP <status> - make sure you are logged in to Instagram'. This surfaces the raw HTTP status of the explore API call and hints the most common cause: an unauthenticated session (401/403) or throttling (429).
Source
Thrown at clis/instagram/explore.js:23
access: 'read',
description: 'Instagram explore/discover trending posts',
domain: 'www.instagram.com',
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of posts' },
],
columns: ['rank', 'user', 'caption', 'likes', 'comments', 'type'],
pipeline: [
{ navigate: 'https://www.instagram.com' },
{ evaluate: `(async () => {
const limit = \${{ args.limit }};
const res = await fetch(
'https://www.instagram.com/api/v1/discover/web/explore_grid/',
{
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();
// Instagram no longer populates the flat layout_content.medias[] path. Media
// objects are now nested across mixed layout shapes (one_by_two_item.clips.
// items[].media, fill_items[].media, etc.), so recursively walk each sectional
// item collecting every distinct node.media and dedupe by pk/id/code. See #2091.
const seen = new Set();
const medias = [];
const collect = (node, depth) => {
if (!node || typeof node !== 'object' || depth > 8) return;
if (Array.isArray(node)) {
for (const item of node) collect(item, depth + 1);
return;
}
const media = node.media;
if (media && typeof media === 'object' && !Array.isArray(media)) {
const key = media.pk ?? media.id ?? media.code;
if (key != null && !seen.has(key)) {View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to Instagram in the browser session, then re-run explore
- Wait and retry if the status is 429 (rate limited)
- Update the CLI if Instagram changed required API headers
- Check the reported status code: 401/403 = auth, 429 = throttle, 5xx = Instagram-side
Example fix
// before: raw throw in evaluate
if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
// after: caller-side retry for transient statuses
try { await explore(); } catch (e) {
if (String(e.message).startsWith('HTTP 429')) { await sleep(60000); return explore(); }
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// before running explore, confirm the session is logged in
const loggedIn = await browserPage.evaluate(() => !!document.cookie.match(/sessionid=/));
if (!loggedIn) throw new Error('Log in to Instagram in the browser session first'); Try / catch
try {
await run(['instagram', 'explore']);
} catch (e) {
const m = String(e.message).match(/^HTTP (\d+)/);
if (m) {
const status = Number(m[1]);
if (status === 429) await sleep(60_000); // retry after backoff
else if (status === 401 || status === 403) /* re-authenticate */;
} else throw e;
} Prevention
- Log in to Instagram in the automation browser before using explore
- Parse the status code in the message to pick auth vs backoff responses
- Space out explore calls to avoid 429s
- Update the CLI if Instagram changes required headers like X-IG-App-ID
When it happens
Trigger: The fetch to https://www.instagram.com/api/v1/discover/web/explore_grid/ inside the page returns a non-2xx status — 401/403 when not logged in or missing X-IG-App-ID acceptance, 429 when rate limited, 5xx from Instagram.
Common situations: Running explore without ever logging into Instagram in the automation browser; expired session cookies; hitting explore too frequently from one IP/account; Instagram changing required headers (X-IG-App-ID or CSRF) and rejecting old requests.
Related errors
- Failed to unsave: HTTP ' + r2.status
- HTTP ' + r2.status + ' - make sure you are logged in to Inst
- ${label} failed: HTTP ${response.status}
- HTTP ${result.httpStatus} from Instagram /users/info
- Failed to follow: HTTP ' + r2.status
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0af039527ed2b98d.
Report an issue: GitHub.