jackwener/OpenCLI · error

HTTP ' + r2.status + ' - make sure you are logged in to Inst

Error message

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

What it means

The feed-by-username endpoint returned a non-OK HTTP status, most commonly 401/403 when the session is missing or Instagram rejects the request. The message deliberately hints the usual cause: not being logged in. Unlike web_profile_info, this endpoint still works for business accounts, so failures are almost always session/rate related.

Source

Thrown at clis/instagram/user.js:28

        { name: 'limit', type: 'int', default: 12, help: 'Number of posts' },
    ],
    columns: ['index', 'caption', 'likes', 'comments', 'type', 'date'],
    pipeline: [
        { navigate: 'https://www.instagram.com' },
        { evaluate: `(async () => {
  const username = \${{ args.username | json }};
  const limit = \${{ args.limit }};
  const headers = { 'X-IG-App-ID': '936619743392459' };
  const opts = { credentials: 'include', headers };

  // Fetch directly by username. web_profile_info is gated for some public
  // accounts even with a valid session, while this feed endpoint still returns
  // the same media item shape this command maps.
  const r2 = await fetch(
    'https://www.instagram.com/api/v1/feed/user/' + encodeURIComponent(username) + '/username/?count=' + limit,
    opts
  );
  if (!r2.ok) throw new Error('HTTP ' + r2.status + ' - make sure you are logged in to Instagram');
  const d2 = await r2.json();
  return (d2?.items || []).slice(0, limit).map((p, i) => ({
    index: i + 1,
    caption: (p.caption?.text || '').replace(/\\n/g, ' ').substring(0, 100),
    likes: p.like_count ?? 0,
    comments: p.comment_count ?? 0,
    type: p.media_type === 1 ? 'photo' : p.media_type === 2 ? 'video' : 'carousel',
    date: p.taken_at ? new Date(p.taken_at * 1000).toLocaleDateString() : '',
  }));
})()
` },
    ],
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log into Instagram in the browser session the CLI uses, then retry.
  2. If 429, back off and slow the request rate.
  3. Clear and re-establish cookies after a password change or logout elsewhere.
  4. Check the exact status code in the message to pick between auth (401/403) and rate (429) fixes.
Defensive patterns

Strategy: try-catch

Validate before calling

const status = await feedStatus(username);
if (status === 401 || status === 403) throw new Error('Login required before listing posts');

Try / catch

try {
  await cli.user(username);
} catch (e) {
  if (e.message.includes('make sure you are logged in')) {
    console.error('Session invalid — open the browser profile and log into Instagram, then retry.');
  } else if (e.message.includes('HTTP 429')) {
    console.error('Rate limited — wait before retrying.');
  } else throw e;
}

Prevention

When it happens

Trigger: GET /api/v1/feed/user/{username}/username/?count=N returns 401/403/429 — no valid session cookie, expired login, or too-frequent calls.

Common situations: Running the CLI without first logging into Instagram in the driven browser; cookies expired after password change; scraping many profiles quickly and hitting throttling.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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