Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static' #11406

Closed
omrllm opened this issue Jan 30, 2019 · 107 comments
Assignees
Labels
good first issue Issue that doesn't require previous experience with Gatsby stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@omrllm
Copy link

omrllm commented Jan 30, 2019

Description

The web app compiles but when I reload the website, the compilation end with an error.

Steps to reproduce

Just type gatsby develop and if you click an article for example or you reload (ctrl + r) the website compilation will end.

Repo: There you go.

Expected result

gatsby develop should work.

Actual result

success open and validate gatsby-configs — 0.015 s
success load plugins — 0.382 s
success onPreInit — 0.606 s
success delete html and css files from previous builds — 0.133 s
success initialize cache — 0.013 s
success copy gatsby files — 0.052 s
success onPreBootstrap — 0.006 s
success source and transform nodes — 0.164 s
success building schema — 0.393 s
success createPages — 0.086 s
success createPagesStatefully — 0.072 s
success onPreExtractQueries — 0.006 s
success update schema — 0.224 s
success extract queries from components — 0.216 s
success run graphql queries — 0.164 s — 14/14 88.14 queries/second
success write out page data — 0.004 s
success write out redirect data — 0.001 s
⢀ onPostBootstrapdone generating icons for manifest
success onPostBootstrap — 0.274 s

info bootstrap finished - 4.655 s

 DONE  Compiled successfully in 1926ms                                                                                                               1:43:58 AM


You can now view abcrypto in the browser.

  http://localhost:8000/

View GraphiQL, an in-browser IDE, to explore your site's data and schema

  http://localhost:8000/___graphql

Note that the development build is not optimized.
To create a production build, use gatsby build

ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
error UNHANDLED EXCEPTION


  Error: ENOSPC: System limit for number of file watchers reached, watch '/home/foldername/abcrypto/static'

  - watchers.js:165 FSWatcher.start
    internal/fs/watchers.js:165:26

  - nodefs-handler.js:37 createFsWatchInstance
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:37:15

  - nodefs-handler.js:80 setFsWatchListener
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:80:15

  - nodefs-handler.js:232 FSWatcher.NodeFsHandler._watchWithNodeFs
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:232:14

  - nodefs-handler.js:414 FSWatcher.NodeFsHandler._handleDir
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:414:19

  - nodefs-handler.js:462 FSWatcher.<anonymous>
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:462:19

  - nodefs-handler.js:467 FSWatcher.<anonymous>
    [abcrypto]/[chokidar]/lib/nodefs-handler.js:467:16

Environment

System:
    OS: Linux 4.20 Fedora 29 (Workstation Edition) 29 (Workstation Edition)
    CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
    Shell: 4.4.23 - /bin/bash
  Binaries:
    Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node
    Yarn: 1.12.3 - /var/lib/snapd/snap/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.3.0/bin/npm
  Languages:
    Python: 2.7.15 - /usr/bin/python
  Browsers:
    Firefox: 64.0.2
  npmPackages:
    gatsby: ^2.0.104 => 2.0.104
    gatsby-cli: ^2.4.8 => 2.4.8
    gatsby-image: ^2.0.29 => 2.0.29
    gatsby-plugin-catch-links: ^2.0.9 => 2.0.9
    gatsby-plugin-feed: ^2.0.12 => 2.0.12
    gatsby-plugin-google-analytics: ^2.0.12 => 2.0.12
    gatsby-plugin-manifest: ^2.0.14 => 2.0.14
    gatsby-plugin-offline: ^2.0.22 => 2.0.22
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.5
    gatsby-plugin-sharp: ^2.0.18 => 2.0.18
    gatsby-plugin-typography: ^2.2.6 => 2.2.6
    gatsby-remark-copy-linked-files: ^2.0.5 => 2.0.8
    gatsby-remark-images: ^2.0.4 => 2.0.6
    gatsby-remark-prismjs: ^3.2.3 => 3.2.3
    gatsby-remark-responsive-iframe: ^2.0.5 => 2.0.8
    gatsby-remark-smartypants: ^2.0.5 => 2.0.7
    gatsby-source-filesystem: ^2.0.18 => 2.0.18
    gatsby-transformer-remark: ^2.2.2 => 2.2.2
    gatsby-transformer-sharp: ^2.1.12 => 2.1.12
  npmGlobalPackages:
    gatsby-cli: 2.4.8
    gatsby: 2.0.98
@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Jan 30, 2019

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

@sidharthachatterjee sidharthachatterjee added the type: question or discussion Issue discussing or asking a question about Gatsby label Jan 30, 2019
@omrllm
Copy link
Author

omrllm commented Jan 30, 2019

Alright I restarted the computer, and now everything works fine again.

@omrllm omrllm closed this as completed Jan 30, 2019
@YamadaKY
Copy link

YamadaKY commented Apr 4, 2019

I solved this way
https://code.visualstudio.com/docs/setup/linux
"Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)#

cat /proc/sys/fs/inotify/max_user_watches

fs.inotify.max_user_watches=524288

tsnieman added a commit to tsnieman/learn-react-hooks that referenced this issue Apr 17, 2019
kentcdodds pushed a commit to epicweb-dev/react-hooks that referenced this issue Apr 17, 2019
@isaacjamesdev
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thank you very much!!!

@jtlindsey
Copy link

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
worked

@QasimRRizvi
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

it saved my day

@chrisobo98
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

I ran this line of code in a react-app and everything went back to normal again, thanks!!

@algol007
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thanks. it's really helpfull

@ravikirany711
Copy link

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Thanks man , you are a hero

@cedricdelpoux
Copy link

cedricdelpoux commented Jul 8, 2019

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Give me the error:
sysctl: illegal option -- p

Using on MacOS

@hoummani
Copy link

Serve your app as root.....It's work!

@cedricdelpoux
Copy link

Serve your app as root.....It's work!

Could you explain ?

@hoummani
Copy link

Run sudo npm run serve inside you app folder or run this commands as below:

  • su
  • enter your password
  • npm run serve

@jessepinho
Copy link
Contributor

Noooooooo don't run your app as root! 💀 🚨 That can cause all kinds of security problems!

@dtran26
Copy link

dtran26 commented Jul 27, 2019

What if I deploy to netlify and encounter that error when netlify tries to build the app? On local it's fine

@himharsh1997
Copy link

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
worked

Yes It is working

@i-bsd
Copy link
Contributor

i-bsd commented Jul 31, 2019

I'm getting this error on Netlify.
Anyone know how to fix it?

@meronek
Copy link

meronek commented Aug 2, 2019

I got it today too and did a "clear cache and redeploy" and it worked.

@wahabAwudu
Copy link

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
worked

worked too. thanks

@GocaninTs
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Works for me. Thank you :D

@johnda98
Copy link

johnda98 commented Mar 20, 2021 via email

@major-winter
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Thanks mate, it saved my day!

@Hamayun-001
Copy link

It’s hitting your system's file watchers limit
Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thank you very much!!!

@smac89
Copy link

smac89 commented Jun 10, 2021

There is a shortcut to setting this parameter. This accomplishes the same thing as the top voted answer:

sudo sysctl fs.inotify.max_user_watches=524288

@johnda98
Copy link

Thanks smac.. u guys rock

@jsdnlb
Copy link

jsdnlb commented Jul 20, 2021

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Worked for me, thank so much!

@Veverke
Copy link

Veverke commented Nov 4, 2021

Error: ENOSPC: System limit for number of file watchers reached,

I am having this issue

Tried echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p but didn't work for me.

Using the sysctl -p approach after setting fs.inotify.max_user_watches did not work for me , either. (by the way this setting was already set to a high value, likely from me trying to fix this issue a while back ago).

The best solution to the problem I found here:

  1. Use this script to identify which processes are requiring the most file watchers in your session.
  2. You can then query the current max_user_watches value with sysctl fs.inotify.{max_queued_events,max_user_instances,max_user_watches} and then set it to a different value (a lower value may do it)
    sudo sysctl -w fs.inotify.max_user_watches=16384
  3. Or you can simply kill the process you found in (1) that consumes the most file watchers (in my case, baloo_file)
  4. The above, however, will likely need to be done again when restarting the system - the process we identified as responsible for taking much of the file watchers will (in my case - baloo_file) - will again so the same in the next boot. So to permanently fix the issue - either disable or remove this service/package. I disabled it: balooctl disable.

Now run sudo code --user-data-dir and it should open vscode with admin privileges this time. (by the way when it does not run sudo code --user-data-dir --verbose to see what the problem is - that's how I figured out it had to do with file watchers limit).

@akshata-systango
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Its working

@cunguyendev
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Worked for me, Linux OS

@Ghostbird
Copy link

Ghostbird commented Jan 6, 2022

Alternative solution for vscode:

Instead of increasing limits you could also add public and .cache folders to files.watcherExclude

"files.watcherExclude": {
    "**/public/**": true,
    "**/.cache/**": true
}

or

image

via https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

This is the actual solution in my case. It turned out that my watcher exclude pattern had an error. It excluded **/node_modules/*/** instead of **/node_modules/**.

Increasing the system's fs.inotify.max_user_watches only helped counter the symptoms of this error, and didn't help any more when even more folders were added to node_modules.

@Ghostbird
Copy link

Ghostbird commented Jan 6, 2022

via https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
Link does not look right.

I just quote-replied and referenced an answer higher up in the conversation.

@haysclark
Copy link
Contributor

I'm running into this issue on Google Kubernetes Engine (GKE) because you don't appear to have the ability to increase the default fs.inotify.max_user_watches.

@dhs-rec
Copy link

dhs-rec commented Oct 7, 2022

Please stop telling people to increase the user watches to such a ridiculously high number. The default value is 8192 for a reason. Each watch consumes 1080 bytes of kernel memory on a 64-bit system. Setting the limit to such a high number would allow EACH USER on the system to potentially allocate number of watches * 1080 bytes of memory.

Tell them to increase the value in small steps until things start to work.

@blaze2004
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

thanks mate, you are a hero

codegod2222 added a commit to codegod2222/react-hook that referenced this issue Nov 24, 2022
pinocchio338 added a commit to pinocchio338/hooks that referenced this issue Dec 29, 2022
@Sugarcothe
Copy link

Sugarcothe commented Jan 10, 2023

If you are getting this error because you are working on a REACT/STRAPI or NODE or something related to javascript and react vis Ubuntu then below will help you.

run this on your terminal

sudo gedit /etc/sysctl.conf

Add a line at the bottom

fs.inotify.max_user_watches=524288

Then save and exit!

sudo sysctl -p

to check it

Then it is solved!

go back to your VS-CODE or any IDE you are using and run your code again

@dhs-rec
Copy link

dhs-rec commented Jan 10, 2023

Please stop telling users to set the limit to such a high value (see my previous comment for the reason).

topstack1226 added a commit to topstack1226/react-hooks that referenced this issue Jan 10, 2023
@Sugarcothe
Copy link

Sugarcothe commented Jan 10, 2023

edited

Please stop telling users to set the limit to such a high value (see my previous comment for the reason).

edited now, thanks

@dhs-rec
Copy link

dhs-rec commented Jan 10, 2023

@Sugarcothe, I don't understand your new value. Now it's even lower than the default (8192).

@motionworks-naveen
Copy link

motionworks-naveen commented Jan 20, 2023

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

above command explanation

This command is using the echo command to write the string "fs.inotify.max_user_watches=524288" to a file called "/etc/sysctl.conf" using the tee command with the -a option, which appends the output to the end of the file. The && operator is used to execute the next command sudo sysctl -p, which reloads the sysctl configuration file and sets the new value.
In brief this command will increase the maximum number of inotify watches that can be created by a single user to 524288. This is useful for certain applications that monitor many files and directories, such as text editors and file managers.

@dhs-rec
Copy link

dhs-rec commented Jan 20, 2023

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

I've created an issue there to fix that document: guard/listen#568

@valgalin
Copy link

Restarting my computer fixed the issue.

@valgalin
Copy link

It’s hitting your system's file watchers limit

Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Read more about what’s happening at https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

I apologize for my last comment that restarting computer fixes the issue. I got it again, and restarting (a lot) didn't solve. So the shared terminal command is really the correct fixed on the issue. If you're like us, try the terminal command.

Thank you much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests