Maaz Zindani

Loading the index…

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

getUserMedia says the requested device was not found

ErrorNotFoundError (DOMException) from getUserMedia

Short answer

NotFoundError means the browser found no camera or microphone that matches what you asked for. Either the machine has no device of that kind, the device is hidden from the page, or your constraints, often an exact deviceId, match nothing. List devices with enumerateDevices first, then loosen the constraints.

  • Applies to Chrome 140+, Firefox 140+, Safari 18+
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the browser which inputs it can see before changing any code. If this list has no videoinput or audioinput, the problem is the device, not your constraints.

    const list = await navigator.mediaDevices.enumerateDevices();
    console.log(list.map(d => `${d.kind}: ${d.label || '(no label)'} ${d.deviceId}`));
  2. 2Match what you see, then jump to its fix

    1. 1The list from enumerateDevices has no videoinput (or no audioinput) but the call asks for video: true (or audio: true)You requested a kind of device the machine does not haveFix
    2. 2OverconstrainedError, or NotFoundError only for users who picked a specific camera earlierA saved deviceId or other exact constraint no longer matchesFix
    3. 3The camera works in other sites or apps but enumerateDevices shows no input on your pageThe browser hides devices from this pageFix

What does the error look like?

  • NotFoundError (DOMException) from getUserMedia
  • OverconstrainedError

Cause 1 of 3

You requested a kind of device the machine does not have

1Check

Compare the kinds in the device list with the keys in your constraints object. A desktop with no webcam fails on video: true even though the microphone works.

const kinds = (await navigator.mediaDevices.enumerateDevices()).map(d => d.kind);
console.log(kinds.includes('videoinput'), kinds.includes('audioinput'));

2Fix

Request only the kinds that exist, or fall back to audio only when no camera is present.

const kinds = (await navigator.mediaDevices.enumerateDevices()).map(d => d.kind);
const stream = await navigator.mediaDevices.getUserMedia({
  audio: kinds.includes('audioinput'),
  video: kinds.includes('videoinput'),
});

3Verify

The promise resolves and the stream has a track of each kind you asked for.

console.log(stream.getTracks().map(t => t.kind));

Confirmed by developer.mozilla.org

Did this fix it?

Cause 2 of 3

A saved deviceId or other exact constraint no longer matches

1Check

Look for exact in your constraints. With exact, the match fails if the property cannot be set to the given value, for example after the user unplugged that camera.

console.log(JSON.stringify(constraints));

2Fix

Use ideal for the saved deviceId, so the browser falls back to the closest device, and catch OverconstrainedError to reset the saved choice.

try {
  stream = await navigator.mediaDevices.getUserMedia({
    video: { deviceId: { ideal: savedDeviceId } },
  });
} catch (err) {
  if (err.name === 'OverconstrainedError') {
    stream = await navigator.mediaDevices.getUserMedia({ video: true });
  } else throw err;
}

3Verify

Unplug the saved camera and reload: the page still starts with another camera.

console.log(stream.getVideoTracks()[0].label);

Confirmed by developer.mozilla.org

Did this fix it?

Cause 3 of 3

The browser hides devices from this page

1Check

Devices are left out of the list when the page has no permission for them or when a Permissions-Policy blocks camera or microphone. Check the response headers and the iframe tag.

curl -sI https://example.com/ | grep -i permissions-policy

2Fix

Allow the features for your page, or for the embedding iframe, and request permission with a normal getUserMedia call.

Permissions-Policy: camera=(self), microphone=(self)

3Verify

Reload and run the first-step command again: inputs now appear.

console.log((await navigator.mediaDevices.enumerateDevices()).length);

Confirmed by developer.mozilla.org

Did this fix it?

How do I stop it coming back?

  • Treat video and audio as optional: read enumerateDevices first and build the constraints from it.
  • Store a chosen deviceId only as ideal, never as exact.
  • Show the user which device is in use, with a picker fed by enumerateDevices.

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.

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Next step

Want this handled for good?

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