vercel/next.js · error

Server is approaching the used memory threshold, restarting.

Error message

Server is approaching the used memory threshold, restarting...

What it means

Warning from the requestListener's finally block in start-server: after every request it calls getMemoryRestartStats with v8 heap statistics, and when used heap approaches the devMemoryThresholdRestart limit the dev server logs this and triggers a restart to reclaim memory before the process is OOM-killed. It is a self-healing measure, not a request failure.

Source

Thrown at packages/next/src/server/lib/start-server.ts:260

    try {
      if (handlersPromise) {
        await handlersPromise
        handlersPromise = undefined
      }
      await requestHandler(req, res)
    } catch (err) {
      res.statusCode = 500
      res.end('Internal Server Error')
      Log.error(`Failed to handle request for ${req.url}`)
      console.error(err)
    } finally {
      const memoryRestartStats = getMemoryRestartStats(
        isDev,
        devMemoryThresholdRestart,
        v8.getHeapStatistics
      )
      if (memoryRestartStats) {
        Log.warn(
          `Server is approaching the used memory threshold, restarting...`
        )
        trace('server-restart-close-to-memory-threshold', undefined, {
          'memory.heapSizeLimit': String(memoryRestartStats.heap_size_limit),
          'memory.heapUsed': String(memoryRestartStats.used_heap_size),
        }).stop()
        flushAllTraces()
        process.exit(RESTART_EXIT_CODE)
      }
    }
  }

  const server = selfSignedCertificate
    ? https.createServer(
        {
          key: fs.readFileSync(selfSignedCertificate.key),
          cert: fs.readFileSync(selfSignedCertificate.cert),
        },

View on GitHub (pinned to 89d017eac4)

Solutions

  1. Reduce server memory usage or increase the memory limit / available memory to avoid restarts.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/next/src/server/lib/start-server.ts:260 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@89d017eac4 (2026-08-19). Data as JSON: /api/errors/14de06a4bedd0870. Report an issue: GitHub.