How to fix Error: ENODEV: no such device, read in Node.js

Node.jsINTERMEDIATEHIGHUpdated Dec 9, 2025ยท 181 views

The ENODEV error occurs when Node.js attempts to read from a device that doesn't exist or is unavailable. This commonly happens with hardware devices like Bluetooth adapters, TTY devices, or when performing device-specific operations on unsupported file descriptors.

Quick fix

Fixes ENODEV

# Check if Bluetooth adapter exists
hciconfig

# List USB devices (for USB Bluetooth adapters)
lsusb | grep -i bluetooth

# Check device status
systemctl status bluetooth
  1. Verify hardware device is connected and recognized
  2. Add error handling for device disconnection
  3. Check and grant required permissions
  4. Configure virtual machine hardware passthrough
node.js โ€” error
# Check if Bluetooth adapter exists
hciconfig
# List USB devices (for USB Bluetooth adapters)
lsusb | grep -i bluetooth
# Check device status
systemctl status bluetooth
Error: ENODEV: no such device, read

What this error means

The ENODEV (Error NO DEVice) error is a system-level error code 19 that indicates "No such device". In Node.js, this error occurs when your application attempts to perform I/O operations on a device that either doesn't exist, has been disconnected, or doesn't support the requested operation. This error is most commonly encountered when working with hardware devices through Node.js, such as Bluetooth adapters, serial ports, input devices, or TTY interfaces. It can also occur when attempting device-specific operations (like ioctl or fcntl) on file descriptors that don't support those operations. The error typically surfaces during the syscall 'read' operation, indicating that Node.js was trying to read data from a device file descriptor when the underlying device became unavailable or was never properly initialized.

Typical symptoms

  • Application crashes with "ENODEV: no such device, read" when initializing hardware
  • Bluetooth or serial port operations fail immediately at startup
  • Error occurs specifically during device binding or initialization in libraries like noble or serialport
  • TTY operations throw ENODEV when attempting to get window size or other TTY-specific calls
  • Error appears after hardware changes, upgrades, or in virtualized environments
  • Stack traces point to HCI socket operations or device read/write calls

Common causes

  1. Hardware device (Bluetooth adapter, serial port, input device) is not physically connected
  2. Device was disconnected or unplugged while the application was running
  3. Running in a virtual machine where hardware devices are not properly passed through
  4. Attempting device-specific operations on file descriptors that don't support them
  5. Bluetooth adapter is disabled in the system or requires elevated permissions
  6. Device driver is not loaded or the device is not recognized by the operating system
  7. TTY operations attempted on non-TTY file descriptors or streams
  8. Hardware platform mismatch after migrating code between different systems

How to fix "Error: ENODEV: no such device, read"

1Verify hardware device is connected and recognized

First, check if the device your application needs is physically connected and recognized by your system.

For Bluetooth devices on Linux:

bash
# Check if Bluetooth adapter exists
hciconfig

# List USB devices (for USB Bluetooth adapters)
lsusb | grep -i bluetooth

# Check device status
systemctl status bluetooth

For serial ports:

bash
# List serial devices
ls -l /dev/tty*

# Check USB serial devices
dmesg | grep tty

If the device is not listed, ensure it's properly connected and drivers are installed.

2Add error handling for device disconnection

Wrap device operations in try-catch blocks to gracefully handle device unavailability:

javascript
const fs = require('fs');

async function readFromDevice(devicePath) {
  try {
    const data = await fs.promises.readFile(devicePath);
    return data;
  } catch (error) {
    if (error.code === 'ENODEV') {
      console.error(`Device not available at ${devicePath}`);
      console.error('Please check device connection and try again');
      // Implement retry logic or graceful degradation
      return null;
    }
    throw error;
  }
}

For Bluetooth libraries:

javascript
const noble = require('@abandonware/noble');

noble.on('stateChange', async (state) => {
  if (state === 'poweredOn') {
    console.log('Bluetooth adapter ready');
    await noble.startScanning();
  } else {
    console.error(`Bluetooth state: ${state}`);
    if (state === 'unsupported') {
      console.error('No Bluetooth adapter found (ENODEV)');
    }
  }
});
3Check and grant required permissions

Many device operations require elevated permissions or specific user group membership.

For Bluetooth on Linux:

bash
# Add user to bluetooth group
sudo usermod -aG bluetooth $USER

# For development, you might need dialout group too
sudo usermod -aG dialout $USER

# Log out and back in for changes to take effect

Grant capabilities to Node.js binary (alternative to running as root):

bash
# Allow Node.js to access raw Bluetooth
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

For serial port access:

bash
# Add user to dialout group
sudo usermod -aG dialout $USER
4Configure virtual machine hardware passthrough

If running in a VM, ensure hardware devices are properly passed through.

For VirtualBox:
1. Power off the VM
2. Go to Settings โ†’ USB
3. Enable USB Controller (USB 2.0 or 3.0)
4. Add USB Device Filter for your Bluetooth adapter or serial device
5. Start the VM and verify device appears in guest OS

For Docker containers, run with privileged mode or specific device access:

bash
# Run with device access
docker run --device=/dev/ttyUSB0 your-image

# For Bluetooth
docker run --privileged --net=host your-image

For WSL2 on Windows:

bash
# USB passthrough requires usbipd
# Install usbipd-win on Windows host
# Then attach USB devices to WSL
5Update device drivers and firmware

Outdated drivers can cause device recognition issues.

On Linux:

bash
# Update system packages
sudo apt update && sudo apt upgrade

# Install bluetooth tools if missing
sudo apt install bluetooth bluez bluez-tools

# Restart bluetooth service
sudo systemctl restart bluetooth

Check kernel modules:

bash
# List loaded bluetooth modules
lsmod | grep bluetooth

# Load bluetooth module if not loaded
sudo modprobe bluetooth

For USB devices, try unplugging and reconnecting:

bash
# Monitor kernel messages when plugging device
dmesg -w
6Verify code compatibility with platform

Ensure your code doesn't assume platform-specific device paths or capabilities.

Use platform-agnostic device detection:

javascript
const os = require('os');

function getBluetoothAvailability() {
  const platform = os.platform();

  if (platform === 'linux') {
    // Check for hci0 device
    const fs = require('fs');
    return fs.existsSync('/sys/class/bluetooth/hci0');
  } else if (platform === 'darwin') {
    // macOS Bluetooth detection
    return true; // Built-in
  } else if (platform === 'win32') {
    // Windows detection
    return true; // Check Windows Bluetooth API
  }

  return false;
}

if (!getBluetoothAvailability()) {
  console.error('No Bluetooth adapter detected');
  process.exit(1);
}

Check library compatibility:

bash
# Some libraries like noble require specific hardware
npm install @abandonware/noble

# Use platform-specific alternatives if needed

Advanced notes

Device File Descriptors and ENODEV

The ENODEV error occurs at the kernel level when a system call fails because the file descriptor doesn't refer to a valid device. In Node.js, this manifests most commonly in three scenarios:

1. Character Device Operations: When using fs.read() or fs.write() on device files in /dev/, the kernel returns ENODEV if the underlying device driver is not loaded or the hardware is absent.

2. TTY Operations: Functions like tty.getWindowSize() perform ioctl system calls that require a TTY device. Calling these on non-TTY file descriptors (like pipes or regular files) results in ENODEV.

3. Socket Binding: Bluetooth HCI sockets and similar low-level network devices return ENODEV during bind() operations if the hardware controller is unavailable.

Debugging Strategies

Use strace to see the exact syscall that's failing:

bash
strace -e trace=read,write,ioctl,bind node your-app.js 2>&1 | grep ENODEV

For Bluetooth debugging:

bash
# Enable HCI debugging
sudo btmon

# Check adapter details
hciconfig hci0 -a

Virtualization Considerations

Virtual machines often don't expose USB devices by default. Even when configured, some VM hypervisors don't properly emulate Bluetooth HCI interfaces. Consider:
- Using native hardware for development
- Running Node.js on the host OS instead of in a container
- Using network-based device access (MQTT, REST APIs) instead of direct hardware access

Production Deployment

For production systems that depend on hardware devices:
- Implement health checks that verify device availability before starting the application
- Use systemd service dependencies to ensure device drivers are loaded
- Set up monitoring alerts for device disconnection events
- Consider hardware redundancy with automatic failover

Frequently asked questions

What does "ENODEV" mean?
The ENODEV (Error NO DEVice) error is a system-level error code 19 that indicates "No such device". js, this error occurs when your application attempts to perform I/O operations on a device that either doesn't exist, has been disconnected, or doesn't support the requested operation. js, such as Bluetooth adapters, serial ports, input devices, or TTY interfaces.
How do I fix "ENODEV"?
The ENODEV error occurs when Node.js attempts to read from a device that doesn't exist or is unavailable. This commonly happens with hardware devices like Bluetooth adapters, TTY devices, or when performing device-specific operations on unsupported file descriptors.
What causes "ENODEV"?
Hardware device (Bluetooth adapter, serial port, input device) is not physically connected Device was disconnected or unplugged while the application was running Running in a virtual machine where hardware devices are not properly passed through
Is the "ENODEV" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading