Maaz Zindani

Loading the index…

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

Chrome rejects getUserMedia with NotAllowedError (permission denied)

ErrorNotAllowedError

Short answer

NotAllowedError means a layer said no: the user or Chrome's site settings blocked the camera, the operating system blocks Chrome from the device, or a Permissions-Policy header forbids it. Check Chrome's site setting first, then the OS privacy setting, then the response headers.

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

Fix it fast

  1. 1Find out which cause you have

    Print the error name and message from the failing call. A NotAllowedError confirms that a permission layer, not a missing device, is the cause.

    navigator.mediaDevices.getUserMedia({ video: true, audio: true })
      .catch(e => console.log(e.name, e.message));
  2. 2Match what you see, then jump to its fix

    1. 1No prompt appears any more, or the user once chose Never allowChrome has the camera or microphone blocked for this siteFix
    2. 2Chrome shows allowed, yet the call still fails; Chrome may offer an Open settings linkThe operating system blocks Chrome from the camera or microphoneFix
    3. 3No prompt at all, and the call rejects at once with NotAllowedError, mostly for embedded pagesA Permissions-Policy header or iframe tag forbids the featureFix

What does the error look like?

  • NotAllowedError
  • getUserMedia rejects with a DOMException named NotAllowedError
  • getUserMedia rejects without ever showing a permission prompt

Cause 1 of 3

Chrome has the camera or microphone blocked for this site

1Check

Open Chrome's site settings for Camera and Microphone and look for your site under the list of sites that are not allowed.

Chrome: Settings > Privacy and security > Site settings > Camera

2Fix

Reset the site's permission to Allow in the site settings (remove the stored block), then reload and accept the prompt.

Chrome: Settings > Privacy and security > Site settings > Camera
(remove the site from "Not allowed to use your camera", or set it to Allow)

3Verify

The site is no longer listed as blocked and getUserMedia resolves after you accept the prompt.

navigator.mediaDevices.getUserMedia({ video: true }).then(s => console.log('ok', s.active));

Confirmed by support.google.com

Did this fix it?

Cause 2 of 3

The operating system blocks Chrome from the camera or microphone

1Check

Open the camera and microphone privacy settings of your operating system and see whether Chrome is switched on. Chrome's own permission dialog can link there with an Open settings option.

(OS privacy settings for Camera and Microphone; the name varies by device)

2Fix

Turn Camera or Microphone on for Chrome in the OS settings, then restart Chrome so it picks the change up.

(toggle in the OS privacy settings; the exact name can vary by device)

3Verify

After restarting Chrome, run the first-step command and see the stream resolve.

navigator.mediaDevices.getUserMedia({ video: true }).then(s => console.log('ok', s.active));

Confirmed by support.google.com

Did this fix it?

Cause 3 of 3

A Permissions-Policy header or iframe tag forbids the feature

1Check

Read the response headers of the page, and the allow attribute of any iframe that loads it.

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

2Fix

Allow camera and microphone for your own origin in the header, and add allow to the iframe when the page is embedded.

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

<iframe src="https://app.example.com/call" allow="camera; microphone"></iframe>

3Verify

Reload the page: a prompt appears and getUserMedia resolves once accepted.

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

Confirmed by developer.mozilla.org

Did this fix it?

How do I stop it coming back?

  • Call getUserMedia from a button click, so the prompt arrives with an obvious reason.
  • Catch NotAllowedError and show how to unblock: site settings first, OS settings second.
  • Keep the Permissions-Policy header in the same config file as the other security headers.

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.