How to Fix the Vite 'ENOSPC' Error on Linux (inotify Watch Limit Exceeded)
If you are working with Vite, React, Vue, or any modern frontend tooling on Linux and suddenly hit this error:
Error: ENOSPC: System limit for number of file watchers reached
syscall: watch
code: ENOSPC
Don’t panic — this is a very common Linux issue, and it’s easy to fix.
This guide explains what the ENOSPC error is, why it happens, and how to fix it temporarily or permanently, so your dev server runs smoothly again.
What Does the Vite ENOSPC Error Mean?
The ENOSPC error does not mean your disk is full.
Instead, it means Linux has hit the maximum number of inotify file watchers allowed for your user.
Tools like:
- Vite
- Webpack
- Rollup
- Next.js
- VS Code
use file watchers to detect changes. Large projects (especially monorepos or those with big node_modules folders) can exceed Linux’s default limit.
Why This Happens Frequently With Vite
Vite is extremely fast because it aggressively watches files. In projects with:
- Many dependencies
- Symlinked packages
- Monorepos
- Docker volumes
…the default Linux watcher limit is often too low.
✅ Temporary Fix (Instant Solution)
This fix works immediately but resets after reboot.
Run the following command:
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl fs.inotify.max_user_instances=1024
Your Vite dev server should now start without errors.
💡 This is the fastest way to unblock yourself.
✅ Permanent Fix (Recommended)
If you don’t want this issue to come back after restarting your system, make the change permanent.
Step 1: Open sysctl configuration
sudo nano /etc/sysctl.conf
Step 2: Add these lines at the end
fs.inotify.max_user_watches=524288
fs.inotify.max_user_instances=1024
Step 3: Apply the changes
sudo sysctl -p
That’s it — your system will now support large projects without hitting the watcher limit.
🔍 Check Your Current inotify Limits
To see your current limits, run:
cat /proc/sys/fs/inotify/max_user_watches
cat /proc/sys/fs/inotify/max_user_instances
If the values are low (e.g. 8192 or 16384), you’re likely to hit the ENOSPC error again.
🚧 No sudo Access? Use Polling Mode (Temporary Workaround)
If you don’t have sudo access (for example on shared servers or CI environments), you can switch Vite to polling mode.
CLI option
vite --watch.usePolling
Vite config option
export default {
server: {
watch: {
usePolling: true,
},
},
};
⚠️ Polling uses more CPU, so this should only be a short-term workaround.
🧹 Reduce Watcher Usage (Optional)
You can also reduce watcher usage by:
- Closing unused VS Code windows
- Stopping other dev servers
- Shutting down unused Docker containers
To roughly estimate open files:
lsof | wc -l
Common Questions
❓ Is ENOSPC a Vite bug?
No. This is a Linux kernel limit, not a bug in Vite.
❓ Does this affect macOS or Windows?
Mostly Linux. macOS and Windows handle file watching differently and rarely hit this limit.
❓ Is it safe to increase inotify limits?
Yes. The recommended values are widely used in production development environments.
TL;DR – Best Fix
Run this command once:
sudo sysctl fs.inotify.max_user_watches=524288
Your Vite ENOSPC error will disappear instantly.
Final Thoughts
If you’re building modern frontend apps with Vite on Linux, increasing inotify limits is almost a mandatory setup step.
Bookmark this guide — it will save you time on future projects 🚀
If this article helped you, feel free to share it with your team or link it in your project documentation.