Skip to main content
Contentstack MCP profile hub is in general availability!

Launch error codes decoded: CF005, CF1001, CF1004, CF003 and more

•
11 min read

Launch returns its own error codes when a request fails at the edge or at your origin. The page shows a short message like Request Timeout CF005 and a status code, and that code tells you exactly which limit you hit or which part of your app failed. Once you know the table, most of these errors take minutes to fix.

This guide is a reference for every public Launch response error code, followed by deeper sections on the ones that come up most: timeouts, body and header limits, oversized response headers, raw RSC payloads in Next.js and the "warming up" screen. The examples use Next.js, but the codes and limits apply to every framework on Launch.

What you'll learn

  • What each Launch error code means and which layer returns it

  • Which platform limit sits behind CF005, CF1001, CF1004 and CF003

  • How to measure request and response headers so you can see the problem

  • How to fix a Next.js page that shows raw RSC data instead of HTML

  • What the "warming up" screen is and when it shows up

Symptoms

Code

Status

Layer

What it means

CFL-0001

500

CDN edge

Your edge function threw an exception or returned an invalid response

CF001

500

Origin

The server process failed to start

CF002

500

Origin

An internal Launch error. Retry, then contact support if it persists

CF003

502

Origin

The response headers are larger than the platform limit

CF004

500

Origin

The origin ran but returned no valid HTTP response

CF1001

413

Origin

The request body is larger than 5 MB

CF1002, CF1003

502

Origin

The path or query string isn't a valid URL under RFC 3986

CF1004

413

Origin

The request headers, usually cookies, are larger than the platform limit

CF005

504

Origin

The origin didn't respond within the request timeout

The messages you see look like this:

Internal Server Error CF001: The server failed to start. Check the Launch Server logs for details.
Bad Gateway CF003: The total size of the response headers exceeded the limit. Check and reduce their size.
Internal Server Error CF004: No valid response from the server. Check the Launch Server Logs and try again.
The request body exceeds the maximum allowed size of 5 MB.

Why it happens

Launch concept: a request first reaches the CDN edge, where edge functions, redirects and rewrites run. If it isn't served from cache, it goes to the origin: your SSR server or Cloud Function. Codes that start with CFL- come from the edge. Codes that start with CF come from the origin.

That split tells you where to look. An edge error means your functions/[proxy].edge.js failed. An origin error means your app failed to start, failed to answer, or sent or received something larger than the platform accepts. The limits that matter here:

Limit

Value

Request headers

About 10 KB, varies slightly per cloud provider

Request body

5 MB (CF1001; the platform limits page lists 128 KB, so test large bodies before you rely on them)

Response headers

32 KB

Response body

5 MB

Request timeout

30 seconds by default, up to 13 minutes on request

Every error has evidence in the server logs. Open the environment in Launch and check Server Logs, or pull them from the terminal with csdx launch:logs --type s. Logs are kept for 24 hours, so forward them with Log Targets if you need history. Logs, debugging and limits covers both.

Fix it

CF005: the request timed out

CF005 returns a 504 when your origin doesn't answer in time. The default request timeout is 30 seconds for every organization. It applies to both buffered and streaming responses.

This usually happens for one of four reasons:

  • A slow downstream call: an external API, a search index or a database that takes 20 seconds on a bad day.

  • A long job inside a request, such as generating a PDF or importing a file.

  • An exception that left the request hanging without a response.

  • Memory pressure that makes every request slower.

Find the slow part first. Log the duration of every external call in the route:

// app/api/search/route.ts
export async function GET(request: Request) {
  const started = Date.now();
  const response = await fetch(`${process.env.SEARCH_URL}?q=${new URL(request.url).searchParams.get('q')}`, {
    signal: AbortSignal.timeout(8000),
  });
  console.log(JSON.stringify({ route: '/api/search', upstreamMs: Date.now() - started, status: response.status }));

  if (!response.ok) {
    return Response.json({ error: 'search unavailable' }, { status: 502 });
  }
  return Response.json(await response.json());
}

AbortSignal.timeout() gives the upstream call a budget below the platform timeout, so you return a clear error instead of a 504.

Then pick a fix:

  • Make it faster. Cache the upstream result, fetch in parallel with Promise.all, and request only the fields you need.

  • Move it out of the request. For work that is long by nature, start a background job, return 202 right away, and let the client poll for the result.

  • Stream the response. In Next.js, enable streaming response mode in the project's build settings so the shell is sent while slower parts load.

  • Ask for a longer timeout. Your Contentstack representative can raise it up to 13 minutes. The response must still start within 98 seconds, and a fully buffered response must finish within those 98 seconds. The new value applies from your next deployment, not to deployments that are already running.

CF1001: the request body is larger than 5 MB

CF1001 returns 413 when a single request body exceeds 5 MB. It shows up with file uploads that go through your own API route, large form posts and Next.js Server Actions that receive files.

Don't send files through your app. Upload them straight from the browser to storage with a signed upload URL, and send only the reference to your route. If your payload is large JSON, remove fields the server doesn't need or split the request.

Next.js has its own, lower limit for Server Actions: 1 MB by default, set with experimental.serverActions.bodySizeLimit in next.config.js. Raising it above 5 MB doesn't help on Launch, because the platform rejects the request first.

CF1004: the request headers are too large

CF1004 returns 413 when the request headers together exceed the limit, which is about 10 KB. Cookies are almost always the cause. Analytics, consent, A/B testing and auth libraries each add their own, and some store whole JSON objects.

The pattern is easy to spot: the site works in a private window and fails in your normal browser, or it fails for returning visitors only.

Measure what the browser sends. In the DevTools console on the failing site, this prints the size of the cookies that JavaScript can read, which is a lower bound:

new Blob([document.cookie]).size

For the full picture, including HttpOnly cookies, open the failing request in the Network tab and check the Cookie request header.

Then trim:

  • Store session data on the server and keep only an ID in the cookie.

  • Set cookies on the narrowest Path and domain that works, so they aren't sent with every request.

  • Remove cookies from tools you no longer use, and expire old ones.

  • Check tag managers and third-party scripts that write large cookies on every page.

Some proxies and servers report oversized headers as 431 Request Header Fields Too Large. That is the generic HTTP status for the same problem. On Launch, the code you see is CF1004 with a 413.

CF003: the response headers are larger than 32 KB

CF003 returns 502 when your app's response headers add up to more than 32 KB. Large Set-Cookie headers are one cause. The sneaky one is a header that grows with content.

A Link header with hreflang alternates is the classic example. A product page in 60 markets lists 60 full URLs in one header. If the slugs are non-ASCII, such as Thai or Japanese, each one is percent-encoded and can be several times longer than its English version. The English page passes, the Thai page returns CF003, and it looks like a locale bug.

Measure the real headers, not the error response. When the limit is hit, Launch replaces your response with a small 502, so measuring the live URL shows tiny headers. Run the app locally and request it over HTTP/1.1, since HTTP/2 compresses headers:

npm run build && npm run start &
curl -s --http1.1 -D - -o /dev/null http://localhost:3000/th/products/some-product | wc -c

Then fix the header that grows:

  • Move hreflang alternates from the Link header into <link rel="alternate"> tags in the HTML <head>, or into your XML sitemap. Search engines accept all three.

  • Remove large custom headers that carry tokens or debug data.

  • Collapse cookies into fewer, smaller Set-Cookie headers.

CF001, CF004 and CFL-0001: the code failed

These three mean your code didn't produce a response.

  • CF001: the server didn't start. Check the server command and the build output directory, start the production build locally with the same command, and look for an out-of-memory crash in the logs.

  • CF004: the server started but returned nothing valid. Usually an unhandled rejection after a failed fetch. Wrap data fetching so every path returns a response with a status code.

  • CFL-0001: the edge function failed. The edge runtime is not Node.js, so process is not defined and other Node APIs throw there. Read environment variables from context.env, and always return a Response. Edge functions in practice covers the runtime.

CF1002 and CF1003: the URL isn't valid

These return 502 when the path or query string breaks RFC 3986. Unescaped spaces, #, % or ? in a path are the usual cause, often from search forms or links built by string concatenation. Build URLs with URL and URLSearchParams, which encode for you:

const url = new URL('/search', 'https://www.example.com');
url.searchParams.set('q', 'cats & dogs 100%');
// https://www.example.com/search?q=cats+%26+dogs+100%25

Raw RSC data instead of HTML after navigation

This one has no error code. In a Next.js App Router app, a page suddenly shows raw, numbered lines of JSON-like data instead of the rendered page. Reloading doesn't help, and it hits every visitor of that URL.

It happens when a client-side navigation hits a redirect:

  1. Next.js requests the next page with an Rsc: 1 header and an _rsc query parameter.

  2. The route redirects, and the browser follows it. It keeps the Rsc: 1 header and drops _rsc.

  3. Next.js sees Rsc: 1 on the new URL and returns the RSC payload.

  4. The CDN caches that payload under the plain URL, because the query parameter is gone. Every later visitor gets it.

Fix it with an edge function that removes the Rsc header when _rsc is missing:

// functions/[proxy].edge.js
export default function handler(request, context) {
  const url = new URL(request.url);
  const hasRscHeader = request.headers.get('rsc') === '1';
  const hasRscParam = url.searchParams.has('_rsc');

  if (hasRscHeader && !hasRscParam) {
    const modified = new Request(request);
    modified.headers.delete('rsc');
    return fetch(modified);
  }

  return fetch(request);
}

Launch's own documentation limits the check to a list of affected paths. Applying it to every path is also safe, because a real RSC request always carries both. After you deploy, the bad copy may still be cached, so revalidate the affected paths as shown in Caching, revalidation and cache priming.

The "warming up" screen after idle

An environment that gets no traffic for a while scales down. The next visitor sees a "warming up" page that reloads by itself once the environment is ready, usually within a few seconds. Production sites with steady traffic don't reach this state.

You mostly see it on staging, preview and demo environments, and on Live Preview first thing in the morning. If that matters, keep the environment warm with a scheduled request to a cheap route, for example from Automate or a scheduled CI job:

// app/api/health/route.ts
export async function GET() {
  return Response.json({ status: 'ok' }, { headers: { 'Cache-Control': 'no-store' } });
}

Check that it worked

  • Request the failing URL with curl -i and confirm the status and body are your app's, not a Launch error message.

  • For CF003, re-measure headers locally over HTTP/1.1 for the largest locale or page.

  • For CF005, check the server logs for the route's duration over the next hour of real traffic.

  • For the RSC problem, open the page in a private window after the revalidation and view the source. It should be HTML.

Prevent it

  • Give every external call a timeout below the platform's 30 seconds.

  • Upload files directly to storage with signed URLs. Never post them through your own route.

  • Keep cookies small and keep session data on the server.

  • Put hreflang alternates in HTML or the sitemap, not in a response header.

  • Keep the RSC edge function deployed on any Next.js App Router site that uses redirects.

  • Forward logs with Log Targets, so you still have the evidence when someone reports an error a day later.

Key takeaways

  • CFL- codes come from the edge, CF codes from the origin.

  • CF005 is the 30-second timeout. Make the work faster, move it out of the request, stream, or ask for a higher ceiling.

  • CF1001 is a body over 5 MB, CF1004 is headers over about 10 KB, and CF003 is response headers over 32 KB.

  • Measure response headers locally over HTTP/1.1, because the live error response hides the real size.

  • Raw RSC data after a navigation is a cached redirect response. Strip Rsc: 1 when _rsc is missing, then revalidate.

Next steps

Frequently asked questions

  • What does CF005 mean on Launch?

    The origin didn't respond within the request timeout, which is 30 seconds by default. Launch returns a 504 with the CF005 message.

  • What is the difference between CF1001 and CF1004?

    Both return 413. CF1001 means the request body is larger than 5 MB. CF1004 means the request headers, usually cookies, are larger than the platform allows.

  • Why does a page return 502 CF003 on some URLs but not others?

    CF003 fires when the response headers add up to more than 32 KB. Headers that grow with content, such as a Link header with many hreflang alternates, push some pages over the limit and not others.

  • Where do CFL errors come from?

    CFL-0001 comes from the CDN edge, which means your edge function threw or returned an invalid response. CF codes come from the origin, your server or Cloud Function.

  • Can I raise the 30 second timeout?

    Yes, up to 13 minutes, by asking your Contentstack representative. The response must still start within 98 seconds, and the new value applies from your next deployment.