{"record":{"id":"020d7060aea812e3","repo":"DIYgod/RSSHub","slug":"invalid-cookie-please-also-check","errorCode":null,"errorMessage":"Invalid cookie.\n                Please also check if your account is being blocked by Instagram.","messagePattern":"Invalid cookie\\.\n                Please also check if your account is being blocked by Instagram\\.","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/routes/instagram/web-api/utils.ts","lineNumber":105,"sourceCode":"\nconst getUserFeedItems = (id, username, cookieJar) =>\n    cache.tryGet(\n        `instagram:feed:${id}`,\n        async () => {\n            const response = await ofetch.raw(`${baseUrl}/api/v1/feed/user/${username}/username/`, {\n                // cookieJar,\n                headers: {\n                    cookie: (await cookieJar.getCookieString(COOKIE_URL)) as string,\n                    ...((await getHeaders(cookieJar)) as unknown as Record<string, string>),\n                    // 401 Unauthorized if cookie does not match with IP\n                    // 'X-IG-WWW-Claim': await cache.get('instagram:wwwClaimV2'),\n                },\n                query: {\n                    count: 30,\n                },\n            });\n            if (response.url.includes('/accounts/login/')) {\n                throw new ConfigNotFoundError(`Invalid cookie.\n                Please also check if your account is being blocked by Instagram.`);\n            }\n\n            return response._data.items;\n        },\n        config.cache.routeExpire,\n        false\n    );\n\nconst getTagsFeed = (tag, cookieJar) =>\n    cache.tryGet(\n        `instagram:tags:${tag}`,\n        async () => {\n            const response = await ofetch(`${baseUrl}/api/v1/tags/web_info/`, {\n                // cookieJar, cookieJar is behaving weirdly here, so we use cookie header instead\n                headers: {\n                    cookie: (await cookieJar.getCookieString(COOKIE_URL)) as string,\n                    ...((await getHeaders(cookieJar)) as unknown as Record<string, string>),","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/instagram/web-api/utils.ts#L87-L123","documentation":"Thrown as `ConfigNotFoundError` in `getUserFeedItems` when the `GET /api/v1/feed/user/:username/username/` response URL contains `/accounts/login/` — the authenticated feed endpoint redirected to login, meaning the cookie is no longer valid for feed reads, OR the account/IP is being blocked. The message additionally prompts checking for account blocks.","triggerScenarios":"Calling the user-feed endpoint after the profile call succeeded but the session is partially invalidated; Instagram rate-limits or soft-blocks the session on feed reads; the session's IP no longer matches (IG ties feed reads to IP more strictly than profile reads).","commonSituations":"Same cookie works for profile but not feed after IG tightens anti-bot; datacenter IP flagged by Instagram; account hit with a temporary restriction; cookie on the edge of expiry.","solutions":["Refresh the cookie and verify the account is not blocked/challenged (log in via browser).","Route RSSHub egress through a residential/stable proxy (set `config.instagram.proxy` or `PROXY_URI`) so the IP matches the cookie's origin.","Slow down requests / raise cache TTL (`config.cache.routeExpire`) to reduce anti-bot triggers.","If persistent, the account may be shadowbanned — use a fresh account."],"exampleFix":"// before: feed read redirected to /accounts/login/\n// after: refresh cookie + pin egress IP\nINSTAGRAM_COOKIE=sessionid=... (fresh)\nPROXY_URI=http://user:pass@residential.proxy:port","handlingStrategy":"retry","validationCode":"// pre-flight: confirm cookie validity on the feed endpoint's domain\nif (!(await checkLogin(cookieJar))) throw new ConfigNotFoundError('Cookie invalid before feed read');","typeGuard":"const redirectedToLogin = (url: string) => url.includes('/accounts/login/');","tryCatchPattern":"try {\n  const res = await ofetch.raw(feedUrl, { headers });\n  if (redirectedToLogin(res.url)) throw new ConfigNotFoundError('Invalid cookie / possible block');\n  return res._data.items;\n} catch (e) { /* one retry with a fresh probe, then surface */ throw e; }","preventionTips":["Pin egress IP to the cookie's origin via a proxy.","Cache feed results to reduce request frequency and avoid anti-bot triggers.","Monitor for repeated login redirects — they signal a block."],"tags":["instagram","cookie","rate-limit","ip-block","web-api"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}