How to Fix ‘tail: inotify cannot be used, reverting to polling’ in Linux

When monitoring active application logs or system events in Linux using the follow flag (tail -f or tail -F), you may observe the terminal output pausing briefly and printing the diagnostic warning: “tail: inotify cannot be used, reverting to polling: No space left on device” or “tail: inotify cannot be used, reverting to polling: Function not implemented”. While the tail command continues to function by periodically polling the file on disk, falling back to polling increases CPU utilization, introduces noticeable lag in log output delivery, and can fail to capture rapid log rotations.

Why tail Reverts from inotify to Polling

Under Linux, the GNU tail utility uses the inotify kernel subsystem to receive immediate asynchronous notifications whenever an inspected file descriptor is written to or modified. Tail falls back to crude polling for two distinct architectural reasons:

  • Exceeded inotify Watch Limits: The system has reached its configured fs.inotify.max_user_watches or fs.inotify.max_user_instances threshold. Modern development tools (such as VS Code, Docker, Webpack, and IDE file watchers) consume thousands of inotify watches simultaneously, exhausting the global allocation table.
  • Unsupported File Systems: The monitored file resides on a remote or virtual filesystem that does not implement the kernel inotify interface. Common examples include Network File System (NFS), Server Message Block (SMB/CIFS) mounts, and certain Docker/Kubernetes overlay volume mounts.

Step 1: Check Current inotify System Watch Limits

Before adjusting kernel parameters, inspect your current usage and limits to determine if watch exhaustion is the culprit.

  1. Open your Linux terminal.
  2. Query the current maximum watch limit by executing:
    cat /proc/sys/fs/inotify/max_user_watches
    (Default values on older systems may be as low as 8192.)
  3. Query the maximum instance limit:
    cat /proc/sys/fs/inotify/max_user_instances
  4. Identify which processes are consuming the largest number of watch instances:
    find /proc/*/fd/* -type l -lname 'anon_inode:inotify' 2>/dev/null | cut -d/ -f3 | sort | uniq -c | sort -nr | head -n 10

Step 2: Increase inotify Watches Temporarily via sysctl

If you need to restore fast event notification immediately without rebooting your Linux server or workstation, raise the watch limit dynamically.

  1. Increase the maximum user watches to 524288 (512K) and instances to 1024:
    sudo sysctl -w fs.inotify.max_user_watches=524288
    sudo sysctl -w fs.inotify.max_user_instances=1024
  2. Verify that the new values took effect:
    sudo sysctl -p
  3. Run your tail -f /path/to/logfile.log command again. The inotify warning will disappear, and logs will stream in real time.

Step 3: Make inotify Limits Persistent Across Reboots

Changes made dynamically with sysctl -w revert upon the next system restart. To persist these allocations, save them to the sysctl configuration directory.

  1. Create or edit a custom configuration drop-in file:
    sudo nano /etc/sysctl.d/60-inotify.conf
  2. Add the following two lines:
    fs.inotify.max_user_watches = 524288
    fs.inotify.max_user_instances = 1024
  3. Save the file and exit the editor (in nano, press Ctrl + O, Enter, then Ctrl + X).
  4. Apply the permanent configuration immediately:
    sudo sysctl --system

Step 4: Handling NFS, CIFS, and Docker Network Mounts

If the file you are tailing resides on a network share mounted via NFS or Samba, the underlying storage protocol cannot send kernel inotify events to your local machine. In this scenario, reverting to polling is normal and unavoidable.

  1. To suppress the warning message cleanly when you know the file is on a network mount, pass the explicit polling interval switch to tail:
    tail ---disable-inotify -s 1 -f /mnt/nfs/server.log
    (The triple dash ---disable-inotify instructs GNU tail to use polling directly without querying inotify, silencing the warning completely.)
  2. The -s 1 flag configures tail to sleep for 1 second between polls, conserving network bandwidth and CPU cycles while still updating frequently.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.