Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

Xiaohongshu's error 300031 doesn't always mean the note is gone

A Xiaohongshu (RedNote) note link can fail in ways that look identical in a browser: a "page not found" (「页面不见了」), a login page, or 「当前笔记暂时无法浏览」 ("this note can't be viewed right now") with error code 300031. If your cod

A Xiaohongshu (RedNote) note link can fail in ways that look identical in a browser: a "page not found" (「页面不见了」), a login page, or 「当前笔记暂时无法浏览」 ("this note can't be viewed right now") with error code 300031. If your code reads share links, treating all of these as "the note was deleted" sends users off to re-copy links that were fine, or tells them a readable note is gone.

These are dated observations from the read logs of a link-reading tool I build, LinkDigest. It reads only the public share page: no login, no cookies. The platform changes, so check against your own tests.

Short version

  • A note page is normally served only with its share token, xsec_token. No token, a wrong token, a private note and a deleted note all land on the same /404/sec_… page.
  • 300031 has at least three meanings. Read it together with which domain the request started on and whether the starting link carried a token.
  • The reason is in the final address, not the page body.

What 300031 turned out to mean

Date (2026) What was seen What it means
29 Oct A note that read at 15:35 came back 300031 from rednote.com at 16:58, while the main site's /explore still served it rednote.com's own 300031 is not a verdict on the note
1 Nov One note read at 08:50 with its token and answered 300031 four minutes later without it, from a server and an ordinary browser alike Here it means "this link has no token"
3 Nov Three links without a token read fine; six others were refused the same morning A missing token is not always fatal: it differs note by note
7 Nov Two complete share links, starting on xiaohongshu.com, were redirected all the way to rednote.com/404?…&error_code=300031&error_msg=当前笔记暂时无法浏览 The link is fine; the platform is not serving this note to signed-out readers

The redirect chain for the 7 November case, seen from a server outside China:

xiaohongshu.com/explore/<id>?…  ->  rednote.com/explore/<id>
    ->  /404/sec_<id>  ->  /404?source=…&error_code=300031&error_msg=当前笔记暂时无法浏览

Two details matter for a fetcher:

  1. These 404 pages are rendered by JavaScript. The sentence may not be in the HTML at all, while error_code and error_msg are in the query string of the final address.
  2. The state changes within a day. One note read at 16:49 and was refused at 17:30. So the honest message is "not readable right now", not "this note is gone".

Two checks, standard library only

The code below makes no requests. before() looks at the link before you fetch it; after() looks at where the request started and where it landed.

from urllib.parse import urlparse, parse_qs, unquote

SHORT = {"xhslink.com", "xhslink.cn"}

def _site(host: str, name: str) -> bool:
    return host == name or host.endswith("." + name)

def before(url: str) -> str:
    """Before any request: look at the link itself."""
    u = urlparse(url)
    host = (u.hostname or "").lower()
    q = parse_qs(u.query)
    if host in SHORT:
        return "short link: follow one redirect and use the full address"
    if not (_site(host, "xiaohongshu.com") or _site(host, "rednote.com")):
        return "not a Xiaohongshu link"
    if "/explore/" not in u.path and "/discovery/item/" not in u.path:
        return "not a note link"
    if "xsec_token" not in q:
        return "no xsec_token: likely a 404, ask for a fresh share link"
    if "xsec_source" not in q:
        return "token but no xsec_source: keep that parameter"
    return "complete"

def after(start_url: str, final_url: str) -> str:
    """After the request: look at where it started and where it landed."""
    start = urlparse(start_url)
    final = urlparse(unquote(final_url))
    host = (final.hostname or "").lower()
    if final.path.startswith("/login"):
        return "login page: says nothing about the note"
    if not final.path.startswith("/404"):
        return "landed on the note page: parse it"
    said = "300031" in final.query or "当前笔记暂时无法浏览" in final.query
    if not said:
        return "page not found: no token, bad token, private or deleted"
    from_main = _site((start.hostname or "").lower(), "xiaohongshu.com")
    if _site(host, "rednote.com") and not from_main:
        return "rednote.com's own 300031: not a verdict on the note"
    if "xsec_token" not in parse_qs(start.query):
        return "300031 and the link had no token: ask for a fresh share link"
    return "300031 on a complete link: a new link won't help, try later"

NOTE = "6a9d0eb2000000002a024480"
ARGS = "xsec_token=CB7rCz&xsec_source=app_share"
MAIN = "https://www.xiaohongshu.com"
RED = "https://www.rednote.com"
SAID = "error_code=300031&error_msg=当前笔记暂时无法浏览"

print("before the request")
for label, url in (
    ("short link from the app", "https://xhslink.cn/o/AxnRePgIokn"),
    ("bare /explore/<id>", f"{MAIN}/explore/{NOTE}"),
    ("xsec_source removed", f"{MAIN}/explore/{NOTE}?xsec_token=CB7rCz"),
    ("complete share link", f"{MAIN}/discovery/item/{NOTE}?{ARGS}"),
    ("the explore feed", f"{MAIN}/explore"),
):
    print(f"  {label} -> {before(url)}")

print("after the request")
full = f"{MAIN}/explore/{NOTE}?{ARGS}"
bare = f"{MAIN}/explore/{NOTE}"
for label, start, final in (
    ("complete link, served", full, full),
    ("no token", bare, f"{MAIN}/404/sec_x?source=/explore/{NOTE}"),
    ("desktop browser, signed out", full, f"{MAIN}/login?redirectPath=x"),
    ("asked rednote.com directly", f"{RED}/explore/{NOTE}", f"{RED}/404/sec_x?{SAID}"),
    ("main site, no token", bare, f"{RED}/404?source=/404/sec_x&{SAID}"),
    ("main site, complete link", full, f"{RED}/404?source=/404/sec_x&{SAID}"),
):
    print(f"  {label} -> {after(start, final)}")

Output:

before the request
  short link from the app -> short link: follow one redirect and use the full address
  bare /explore/<id> -> no xsec_token: likely a 404, ask for a fresh share link
  xsec_source removed -> token but no xsec_source: keep that parameter
  complete share link -> complete
  the explore feed -> not a note link
after the request
  complete link, served -> landed on the note page: parse it
  no token -> page not found: no token, bad token, private or deleted
  desktop browser, signed out -> login page: says nothing about the note
  asked rednote.com directly -> rednote.com's own 300031: not a verdict on the note
  main site, no token -> 300031 and the link had no token: ask for a fresh share link
  main site, complete link -> 300031 on a complete link: a new link won't help, try later

The last two lines are the point. Both requests ended on the same international-domain 404 page, and what you should tell the user differs: one needs a freshly copied link, and for the other a new link changes nothing.

Three mistakes that cause most of this

Copying the address bar instead of the share link. An address typed from a screenshot, taken from a search result or "cleaned" by a tool is often just /explore/<id>. Only the app's Share → 复制链接 (Copy link) gives the token.

Normalising the URL. Dropping the query string, or keeping only the id as a cache key, is a common habit. For Xiaohongshu, xsec_token and xsec_source have to go out with the request unchanged. The cache key may drop them; the request may not.

Retrying in a loop. On 18 November one reader submitted the same app-only note six times in half an hour and got the same sentence every time, each try walking the whole redirect chain. What works better is to remember the platform's answer per note id for a short while (we keep it ten minutes) and answer from memory. Don't remember an answer given to a link without a token, because a fresh link with one deserves a real try.

When a note won't read, stop. Rotating exits or borrowing someone's cookies to push through is not a fix; say plainly that it can't be read.

Summary

  • Before the request: expand short links, and ask for a fresh share link when xsec_token is missing.
  • After the request: /login tells you nothing, /404/sec_… hides its cause, and 300031 needs the start domain and the token to interpret.
  • Report an unreadable note as an explicit failure, never as a success with an empty body.

The measurements behind the token rules (one note, nine ways of writing its link) are in a longer write-up: Xiaohongshu note link returns 404 or error 300031? Check the xsec_token.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.