Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Node.js dev server stops with ENOSPC although the disk has free space

ErrorError: ENOSPC: no space left on device, watch '/path/to/project'

Short answer

ENOSPC does not always mean a full disk. On Linux, file watchers use inotify, and each user may create only a limited number of watches. When the limit is reached, adding a watch fails with ENOSPC. Compare the limit with the folder size, raise fs.inotify.max_user_watches, and check disk space as the second cause.

  • Applies to Node.js 22, Ubuntu 24.04, Linux kernel 6.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the last word of the message. A failing watch points to the inotify limit, a failing write points to the disk. Then print both numbers.

    cat /proc/sys/fs/inotify/max_user_watches
    df -h .
  2. 2Match what you see, then jump to its fix

    1. 1ENOSPC with the word watch while a dev server or test watcher starts, and df shows free spaceThe per-user inotify watch limit is too low for the projectFix
    2. 2ENOSPC with the word write while installing, building or loggingThe disk really is fullFix

What does the error look like?

  • Error: ENOSPC: no space left on device, watch '/path/to/project'
  • Error: ENOSPC: no space left on device, write

Cause 1 of 2

The per-user inotify watch limit is too low for the project

1Check

On Linux, Node.js file watching uses inotify. The kernel caps the number of watches per user, and the call that adds a watch fails with ENOSPC when the user limit is reached. Large node_modules folders and several watchers at once use the limit up quickly.

cat /proc/sys/fs/inotify/max_user_watches
find . -type d -not -path '*/node_modules/*' | wc -l

2Fix

Raise the limit. First change it for the running system, then keep it across reboots with a file in /etc/sysctl.d.

echo 524288 | sudo tee /proc/sys/fs/inotify/max_user_watches
echo "fs.inotify.max_user_watches=524288" | sudo tee /etc/sysctl.d/99-inotify.conf

3Verify

Read the value back and start the watcher again.

cat /proc/sys/fs/inotify/max_user_watches
npm run dev

Confirmed by man7.org

Did this fix it?

Cause 2 of 2

The disk really is full

1Check

A write fails with ENOSPC when the device holding the file has no room for the data. Find which folder holds the space.

df -h
du -xh --max-depth=1 . | sort -h | tail -n 10

2Fix

Remove what you can regenerate, such as build output and caches, or move large logs elsewhere. Then retry the failed command.

rm -rf .next dist build
npm cache clean --force

3Verify

Confirm there is free space again and rerun the command that failed.

df -h .

Confirmed by man7.org

Did this fix it?

How do I stop it coming back?

  • Tell the watcher to ignore node_modules and build folders so it adds fewer watches.
  • Keep the sysctl.d file in your server setup notes so a new machine gets the same limit.
  • Add a disk usage alert to servers that run builds or write logs.
  • Run one watcher per project instead of several tools watching the same tree.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.