getUserMedia says the requested device was not found
NotFoundError (DOMException) from getUserMediaShort 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.
Fix it fast
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}`));2Match what you see, then jump to its fix
- 1
The 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
OverconstrainedError, or NotFoundError only for users who picked a specific camera earlierA saved deviceId or other exact constraint no longer matchesFix - 3
The camera works in other sites or apps but enumerateDevices shows no input on your pageThe browser hides devices from this pageFix
- 1
What does the error look like?
NotFoundError (DOMException) from getUserMediaOverconstrainedError
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
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
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-policy2Fix
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
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
navigator.mediaDevices is undefined, so getUserMedia cannot be called
navigator.mediaDevices is undefined
Browsers only expose navigator.mediaDevices on secure pages: HTTPS, localhost or file://.
3 causes, each with a fixBack end
Airflow SSHOperator stops a long script with SSH command timed out
airflow.exceptions.AirflowException: SSH command timed out
SSHOperator waits only 10 seconds for a command by default.
3 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack 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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fix