// troubleshooting guide · posthog

PostHog Node Not Sending Events in Serverless (Vercel, Lambda, Next.js)

Status
Workaround available
platforms:
Node.js, Next.js, Vercel, AWS Lambda, Cloudflare Workers
updated:
November 23, 2026
reports:
3
Method
how we research
Share

RUNBOOK · posthog/serverless-events-missing4 FIXES

// quick answer

posthog-node batches events and sends them later, so a serverless function that freezes after returning its response drops them. Set flushAt to 1 and flushInterval to 0, then await shutdown() (or flush()) before the function ends.

Most likely fix: Send each event immediately in serverless code

How to fix it

// try these in order, the most common fix is first

  1. FIX 1Send each event immediately in serverless code

    1. 01Create the client with new PostHog(token, { host, flushAt: 1, flushInterval: 0 })
    2. 02Use this only for serverless or edge code; a long-running Node server should keep the default batching with one shared client
    Did this fix it?
  2. FIX 2Await shutdown before the function returns

    1. 01After capturing, call await posthog.shutdown() before returning the response
    2. 02On Next.js 15.1 or later, wrap it in after(() => posthog.shutdown()) so the request is sent after the response without delaying it
    3. 03Do not reuse a client after shutdown(); use flush() for per-request cleanup on a shared client
    Did this fix it?
  3. FIX 3Bound the flush on AWS Lambda

    1. 01flush() has no overall timeout, so race it against context.getRemainingTimeInMillis() minus about 100 ms
    2. 02Keep the handler awaiting the race so Lambda does not freeze mid-request
    Did this fix it?
  4. FIX 4Confirm the server can reach PostHog

    1. 01Temporarily set host to a webhook.site URL and trigger the route
    2. 02If nothing arrives, fix initialization; if it arrives, set host back to https://us.i.posthog.com or https://eu.i.posthog.com to match your project
    Did this fix it?

SANDBOX · posthog RUNS IN YOUR BROWSER

Try it: chart events, find the funnel drop-off, watch the session, roll out a flag

A hands-on PostHog-style sandbox, including the spots where users get stuck. See where problems like this one start. 1-2 minutes, nothing is saved.

Symptoms

Server-side events from API routes, Server Actions, Lambda handlers or edge functions never appear, or only some of them do, while the same code works locally with a long-running server.

Why it happens

  • C-01The SDK queues events (default flushAt 20, flushInterval 10 seconds) and the function is frozen before the queue is sent
  • C-02shutdown() or flush() is never awaited at the end of the request
  • C-03A new client is created per request without shutting it down
  • C-04Wrong project token or region host on the server (US vs EU)

// this guide also covers

  • posthog node not sending events
  • posthog serverless events missing
  • posthog vercel events not showing
  • posthog lambda events lost
  • posthog-node shutdown
  • posthog flushAt 1

Still not working?

If PostHog keeps failing, you're not alone. See every PostHog problem users report or the alternatives people switch to.

Done fighting PostHog? Our small team builds your own PostHog alternative, or any software you need: web, mobile, games, desktop. Price agreed together.

Talk to us

Watch PostHog Get an email when its price changes, it has an outage, or we publish a new fix. No spam.

Fixed it? Share this guide

The same problem in other apps

All missing or lost data guides →

Other PostHog errors

All 18 PostHog errors and fixes →