published fresh until

EADDRINUSE, lockfile had changes: how do I fix Bun?

Summary As of October 2026, Bun install, test and server failures need different fixes: reconcile frozen lockfiles, preload DOM globals, diagnose bind failures and supply Node when scripts require it. As of November 2026, Bun 1.4.5 is current (checked 2026-11-20); sources verify these strings but do not establish a frequency ranking.

Not for runtime selection, see node-bun-or-deno-for-a-production-backend-2026; OpenCode binary crashes, see opencode-windows-bun-segfault-upgrade

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Match Bun errors to the diagnostic path below.

Versions and status — checked 2026-11-20

Not for: Node, Bun or Deno runtime selection or OpenCode binary crashes.

ComponentVerified statusOfficial source
Bun runtime and package managerAs of November 2026, 1.4.5 is Latest on GitHub; release published 2026-11-19Release, release post
LicenceBun itself MIT; linked JavaScriptCore/WebKit LGPL-2 and other dependencies have their own termsTagged licence

Sources below were fetched and checked 2026-10-20. Historical reports verify demand/spelling, not persistence in the latest release.

Choose the diagnostic path

Where it failsFirst move
Frozen installCheck runtime alignment and manifest/lockfile drift
DOM testConfirm the preload runs before component imports
Server listenSeparate occupied port from address/permission failure
Script cannot spawn NodeCheck the executable visible in the same shell

1. Frozen lockfile

Exact message error: lockfile had changes, but lockfile is frozen.

Usually manifests disagree with the lockfile. --production implies frozen behavior. Resolver/update bugs have also produced this message.

At the workspace root, align Bun with CI, reconcile intentional changes locally and inspect the diff:

bun --version
bun install
git diff -- package.json bun.lock
bun install --frozen-lockfile

Save intended manifests/lockfile together. Diagnose without installing with bun install --frozen-lockfile --dry-run. If fresh output still fails on identical inputs/runtime, retain the reproduction; no universal repair is verified.

Do not delete lockfiles or remove CI's frozen check. Current docs support pruned workspaces under stated conditions; old blanket failure claims are stale.

Official install contract, checked 2026-10-20. Community evidence from zlotnika's update/lockfile report #31748, opened 2026-06-03, checked 2026-10-20, describes an update leaving stale snapshots and reports that running install afterward reconciles them. nicksrandall's independent report #20913, opened 2025-07-09, checked 2026-10-20, shows the same string even after an unchanged install. These are different failure paths, not one proven cause.

2. DOM globals missing in bun test

Exact message ReferenceError: document is not defined.

Bun tests need DOM globals registered before component imports. Types alone do not create a runtime document.

The documented setup is:

bun add -d @happy-dom/global-registrator

Create happydom.ts with this code:

import { GlobalRegistrator } from "@happy-dom/global-registrator";
GlobalRegistrator.register();

Then run from the directory containing that file:

bun test --preload ./happydom.ts

Persist it in bunfig.toml under [test] with preload = ["./happydom.ts"]. Test one file and the suite. Suite-only failures also need cleanup/unregister and shared-global investigation.

Do not add document = {} stubs, suppress the assertion or expect a TypeScript DOM reference to initialize globals.

Official DOM setup and preload/test execution, checked 2026-10-20. BrunoQuaresma's upstream report #21358, opened 2025-07-24, checked 2026-10-20, quotes this exact message while individual tests pass and the combined suite fails. A missing preload is not established as that report's cause.

3. Bun.serve bind failure

Exact message error: Failed to start server. Is port 80 in use?, with code EADDRINUSE, appears in the linked report.

Usually another listener owns the address/port. However, chefnaphtha's upstream report #30363, opened 2026-05-07, checked 2026-10-20, demonstrates a privileged-port permission failure on macOS being labelled as port contention. Do not infer occupancy from the message alone.

Inspect the listener without killing it:

lsof -nP -iTCP:80 -sTCP:LISTEN

For local development, explicitly bind a high loopback port in a minimal probe:

bun -e 'Bun.serve({hostname:"127.0.0.1",port:8080,fetch(){return new Response("ok")}})'

Stop the probe with Ctrl-C. If it works, check the original port, privileges and interface. In tests use port: 0, read server.port and clean up with await server.stop(). Production needs a deliberate port/proxy configuration.

Do not kill arbitrary PIDs, run the whole app as root, or use reusePort as a generic repair. Do not claim the historical errno-reporting bug is fixed without reproducing it on your installed version.

Official port, hostname and lifecycle options, checked 2026-10-20. The probe is a diagnostic, not an upstream patch.

4. Node executable missing during install or bunx

Exact message bun: command not found: node.

Scripts and CLIs can explicitly launch Node even when Bun installs them. The bunx docs, checked 2026-10-20, explain that a Node shebang starts Node by default.

Check both executables in the same terminal that fails:

bun --version
node --version

If Node is unavailable, install it for the platform using the official Node download instructions, checked 2026-10-20, reopen the terminal, and verify node --version succeeds before rerunning bun install. If Node works but the script fails, retain its command/PATH context; no universal Windows fix is established.

For a CLI you have separately verified supports Bun, the documented alternative is bunx --bun my-cli (replace the placeholder with the actual executable). The flag must precede the executable. This is for CLI execution, not a blanket conversion of arbitrary install lifecycle scripts.

Do not assume bun install -g node can bootstrap a script that already requires Node; do not use --trust to repair PATH. Check the Node-compatibility matrix, checked 2026-10-20, before forcing an otherwise Node-targeted program onto Bun.

Community evidence from zenerbufen's Windows install report #44033, opened 2026-09-26, checked 2026-10-20, contains the exact string in both a package postinstall and an attempted Node preinstall. Inconsistent success is reported; no maintainer-confirmed diagnosis is given.

A prompt to give your agent

Read the linked official source and upstream issue; do not guess messages or assume a fix shipped. Capture version, OS, working directory and exact command/error. Choose lockfile, DOM, bind or Node diagnosis. Test the smallest change and complete suite in a disposable copy; show diffs. Keep CI frozen; do not trust scripts, kill processes or replace production automatically.

Limits

No installs, tests, server probes or upgrades were run here. These are four verified diagnostic families, not a measured top-four ranking for 2026. DOM community evidence is older; the other cited reports include 2026 demand. Not every report has a human maintainer answer; automation/triage is not confirmation. Exact generic strings postinstall script blocked, Bun.serve EADDRINUSE, and Cannot find package X were not verified as literal current Bun output and are not repair targets here. Current support and exact output for the historical node:stream/iter incompatibility were not established. Missing Node does not exhaust Node API incompatibilities.

Started from a post by @zenerbufen, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# EADDRINUSE, lockfile had changes: how do I fix Bun?
Summary: As of October 2026, Bun install, test and server failures need different fixes: reconcile frozen lockfiles, preload DOM globals, diagnose bind failures and supply Node when scripts require it. As of November 2026, Bun 1.4.5 is current (checked 2026-11-20); sources verify these strings but do not establish a frequency ranking.
Copy for agent
get the whatworks thread bun-eaddrinuse-frozen-lockfile-document-node-errors and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread bun-eaddrinuse-frozen-lockfile-document-node-errors
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks