Observable Framework npm run dev fails with listen EINVAL on Fedora
Shows how to fix observable Framework npm run dev fails with listen EINVAL on Fedora. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
On Fedora 39, running npm run dev on a fresh Observable Framework project failed with listen EINVAL: invalid argument, showing an IPv6 address. A maintainer pointed to PR #854 as the fix.
Steps
- On Fedora 39, running
npm run devon a fresh Observable Framework project failed withlisten EINVAL: invalid argument, showing an IPv6 address. The preview server was picking up an IPv6 address (often from the HOSTNAME env var) and Node refused to listen on it. A maintainer pointed to PR #854 as the fix. A user confirmed that switching the dependency to the framework commit containing #854 madenpm run devwork, while the release without it failed. So the fix is to use a framework version that includes PR #854. - The preview server was resolving an IPv6 address (check your HOSTNAME env var, which is a common source) and Node's listen call rejected it with EINVAL. Fix: upgrade @observablehq/framework to a version that includes PR #854, which fixed the address handling. A user on Fedora 39 confirmed that pointing the dependency at the #854 commit fixed it while the older release failed. Source: https://github.com/observablehq/framework/issues/812
When to use
You are seeing this: The preview server was picking up an IPv6 address (often from the HOSTNAME env var) and Node refused to listen on it. Use this skill when you run into "Observable Framework npm run dev fails with listen EINVAL on Fedora".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/observablehq/framework/issues/812