⚡UltraStack Errors
INCIDENT RUNBOOK

Fix: Dynamic Server Usage in Express on Fly.io

Comprehensive architectural post-mortem and verified configuration patch for express deployed in fly.io production environments.

Automated Remediation ProtocolUpdated for 2026 Production

Facing dynamic-server-usage in CI/CD or runtime containers?

Review the verified configuration patches below. To automate incident triage and fine-tune your own internal agents, check out our production AI training datasets.

● Observed Terminal Error / Stack Trace

Error: ENOENT: no such file or directory, scandir '/usr/local/lib/node_modules/express/node_modules/send/node_modules/ms/index.js'
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:18)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/app/server.js:3:18)

Root Cause Analysis

The error occurs due to the dynamic nature of server usage in Express applications deployed on Fly.io. By default, Fly.io expects a static server configuration, but Express dynamically spawns new server instances based on incoming requests, leading to a mismatch between expected and actual server usage. This discrepancy causes the application to crash or become unresponsive, resulting in the 'dynamic-server-usage' error.

● Configuration & Code Resolution

To resolve the issue, update the `fly.toml` configuration file to include the following lines:
[build]
  command = "npm run build"
[deploy]
  strategy = "canary"

Then, modify the `package.json` file to include a new script for building the application:
"scripts": {
  "build": "node./build.js",
  "start": "node./server.js"
}
Create a new file named `build.js` with the following content:
const express = require('express');
const app = express();
app.use(express.static('public'));
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`Server listening on port ${port}`);
});

Verification & Build Command

fly deploy --config fly.toml && fly status --app <app-name>