DIYgod/RSSHub · error · ConfigNotFoundError
Invalid cookie
Error message
Invalid cookie
What it means
Thrown as `ConfigNotFoundError('Invalid cookie')` in `getUserInfo` (web-api/utils.ts:68-70). After calling `GET /api/v1/users/web_profile_info/?username=...`, if the response URL contains `/accounts/login/` it means Instagram redirected the API call to the login page — i.e. the request was treated as unauthenticated. The cookie header supplied is invalid/missing for this endpoint.
Source
Thrown at lib/routes/instagram/web-api/utils.ts:69
let id = await cache.get(`instagram:getIdByUsername:${username}`);
let userInfoCache = await cache.get(`instagram:userInfo:${id}`);
userInfoCache = userInfoCache && typeof userInfoCache === 'string' ? JSON.parse(userInfoCache) : userInfoCache;
if (!userInfoCache) {
try {
const response = await ofetch.raw(`${baseUrl}/api/v1/users/web_profile_info/`, {
// cookieJar,
headers: {
cookie: (await cookieJar.getCookieString(COOKIE_URL)) as string,
...((await getHeaders(cookieJar)) as unknown as Record<string, string>),
// 'X-IG-WWW-Claim': (await cache.get('instagram:wwwClaimV2')) ?? undefined,
},
query: {
username,
},
});
if (response.url.includes('/accounts/login/')) {
throw new ConfigNotFoundError('Invalid cookie');
}
webProfileInfo = response._data.data.user;
id = webProfileInfo.id;
await cache.set(`instagram:getIdByUsername:${username}`, id ?? '', 31_536_000); // 1 year since it will never change
await cache.set(`instagram:userInfo:${id}`, webProfileInfo);
} catch (error) {
if ((error as Error).message.includes("Cookie not in this host's domain")) {
throw new ConfigNotFoundError('Invalid cookie');
}
throw error;
}
}
return userInfoCache || webProfileInfo;
};
View on GitHub (pinned to bed535e087)
Solutions
- Refresh `INSTAGRAM_COOKIE` with a current browser session.
- Make sure the cookie string includes all required cookies (`sessionid`, `ds_user_id`, `csrftoken`, `ig_did`, `mid`, `ig_nrcb`).
- Check the account is not temporarily restricted; clear the `instagram:getIdByUsername` / `instagram:userInfo` cache entries that may hold a stale/empty id.
Example fix
// before: response.url.includes('/accounts/login/') -> throw
// after: supply a complete, fresh cookie
INSTAGRAM_COOKIE=sessionid=...; ds_user_id=...; csrftoken=...; ig_did=...; mid=...; Defensive patterns
Strategy: try-catch
Validate before calling
// none — detection is post-response (redirect URL). Pre-check cookie presence:
if (!cookie) throw new ConfigNotFoundError('INSTAGRAM_COOKIE not set'); Type guard
const redirectedToLogin = (url: string) => url.includes('/accounts/login/'); Try / catch
try {
const res = await ofetch.raw(url, { headers: { cookie } });
if (redirectedToLogin(res.url)) throw new ConfigNotFoundError('Invalid cookie');
} catch (e) { if (/Cookie not in this host/.test((e as Error).message)) throw new ConfigNotFoundError('Invalid cookie'); throw e; } Prevention
- Treat any redirect to /accounts/login/ as an auth failure.
- Keep the cookie complete (all required IG cookies).
- Clear cached empty ids when the cookie is refreshed.
When it happens
Trigger: Calling the user-profile-info endpoint with a cookie that has expired or lacks the required session cookies; Instagram silently redirects unauthenticated API calls to `/accounts/login/` instead of returning 401.
Common situations: Cookie expired between the `checkLogin` probe and this call; cookie present but missing `sessionid`/`ds_user_id`; rate-limited/soft-logged-out session; server IP mismatch.
Related errors
- Invalid cookie. Please also check if your ac
- Invalid cookie
- Instagram RSS is disabled due to the lack of <a href="https:
- Baidu security verification required. The cookie may be expi
- Baidu Tieba RSS is disabled due to the lack of <a href="http
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/4f05c765e18336f4.
Report an issue: GitHub.