Google chrome DOMException: Permission denied by system for navigator.mediaDevices.getUserMedia
Asked Answered
I

7

22

It's November of 2019, this JavaScript code works in FireFox (70.0.1 (64-bit)), Safari (13.0.2 (15608.2.30.1.1)), Opera (Version:65.0.3467.48), On a Windows Chrome Version 70.0.3538.77 (64-bit), this code works. but NOT in MacOS Google Chrome (Version 78.0.3904.108 (Official Build) (64-bit)):

navigator
.mediaDevices
.getUserMedia({video: true, audio: true})
.then(stream => {
    console.log("success!")
})
.catch(e => {
    console.log("e: ", e);
});

In Chrome's console, I got: DOMException: Permission denied After much googling, I haven't found anything up to date. How exactly do we use JS to request camera access in Chrome?

Inelastic answered 22/11, 2019 at 19:26 Comment(5)
Check your settings that you didn't accidentally reject or disable the use permission at some point: Settings -> Site Settings -> CameraEstelaestele
If I specifically set the site's camera settings to "Block", I get the same exception. It should be set to "Ask".Commination
@PatrickEvans, I checked, it's set to "Ask". Still I got the message, indeed the same message that would show up when that very setting is "Blocked" as mentioned by Ernest. You will see what I mean if you paste my code into Chrome console.Inelastic
Have you checked this: github.com/webrtc/samples/issues/1191 Also does this page ask for a microphone? webrtc.github.io/samples/src/content/getusermedia/audioCommination
@Ernest, webrtc.github.io/samples/src/content/getusermedia/audio does work fine in my Chrome, but when I use the source code locally, I go NotAllowedError. Finally the solution lies in System Preferences > Security & Privacy > Privacy > Camera & Microphone as jib mentioned below.Inelastic
C
16

Since MacOS Mojave, camera and microphone require OS permissions.

This applies to all non-Apple products, including all browsers other than Safari.

Check System Preferences > Security & Privacy > Privacy > Camera & Microphone. Make sure Chrome is listed and has a checkbox.

You should have gotten a special OS prompt about this the first time Chrome tried to access them. But if it accidentally got blocked somehow, you won't ever be prompted again.

Chairborne answered 24/11, 2019 at 3:10 Comment(1)
I am getting the error on a Windows machine, inside an app that loads an HTML page containing the native camera feature code.Durware
S
10

In my case, I did not realize the project I was working in was adding a security header, blocking the possibility of microphone use:

Feature-Policy "microphone 'none'; geolocation 'none'"

Septal answered 25/5, 2021 at 16:16 Comment(2)
it helped it me! and I have remove mcrophone key from header!Taconite
This fixed it for me too - there was a HeaderPolicyCollection() that was injecting this to all headers in my ASP.NET applicationSalary
N
5

Windows 11 - Microphone Privacy Settings fix

From the other solutions it sounds like a variety of issues could be causing this problem. For me (Windows 11, Google Chrome) this issue was caused by my microphone being disabled in my Windows privacy settings.

To fix, click Start and search for "Microphone Privacy Settings". In the control panel that pops up, switch "Microphone access" to on.

Nedi answered 15/4, 2022 at 20:16 Comment(1)
thank $god I found this!Hatty
C
1

In my case, this error was occurring for me even though the site in question did not appear under blocked sites on the microphone setting page.

I had to go to Site Settings -> View Permissions and Data stored across all sites -> Find my Site -> Click Reset Permissions to fix the issue.

Clicker answered 2/4, 2020 at 18:43 Comment(0)
C
1

Feature-Policy has now been renamed to Permissions-Policy in the spec, and this article will eventually be updated to reflect that change. src

In my case, I set a header with an empty parentheses

Permissions-Policy: microphone=()

and according to this document, it disables the access.

The empty allowlist ensures that the feature is disabled in all contexts everywhere.

So changing the header to

Permissions-Policy: microphone=(self)

solved my problem.

Cetacean answered 5/12, 2021 at 12:4 Comment(0)
H
0

It seems, on your browser media is disabled, try to enable your media source video/audio on your chrome browser

Homiletic answered 1/12, 2021 at 12:22 Comment(0)
P
-1

I got the same error in a slightly different case (on Windows 10, Chrome): I was running a local server and accessed my own website from http://127.0.0.1:5500/. The solution was to access it from http://localhost:5500/ instead.

Phylloquinone answered 2/1, 2021 at 18:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.