36

I cloned a project about real-time image processing on a web browser from this link: Then I could not allow my browser to access my camera. I got this javascript alert:

Uh-oh, the webcam didn't start. Do you have a webcam? Did you give it permission? Refresh to try again. And the allow button is not shown as if I access his site.

2
  • Did you give your website the media permission in your browser? (click the icon next to the URL to see) edit sometimes local files have even tighter security
    – Paul S.
    May 30, 2013 at 11:55
  • This link might help someone.
    – Ishaan
    Jan 27, 2021 at 8:05

10 Answers 10

54

To ignore Chrome’s secure origin policy, follow these steps.

Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure in Chrome.

Find and enable the Insecure origins treated as secure section (see below).

Add any addresses you want to ignore the secure origin policy for. Remember to include the port number too (if required).

Save and restart Chrome.

I found solution from below link.Hope it will help to someone

https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339

2
  • This will also work with Brave browser. Replace chrome://... with brave://..
    – Franco B
    Feb 22, 2021 at 9:17
  • this is no longer working
    – MrCujo
    Oct 26 at 16:47
30

Are you accessing the webpage that is served over HTTP, on localhost? If you are accessing it from http://localhost/... , Chrome will ask for your permission to use the camera.

Chrome accessing camera on localhost

If you are opening the web page directly, i.e. /Users/Methuz/Documents/index.html then it will not work, even if you explicitly allows it permission

Chrome cannot access camera over file protocol


In this case, the workaround I use is to host the HTML file on a webserver. A quick hack is to use python, in the folder where the HTML page is lcoated: python -m SimpleHTTPServer

5
  • 2
    I use this solution too, but at every refresh it asks me camera permissions again, any idea how to "save" those permissions for "localhost:8000" ?
    – ricricucit
    Mar 4, 2014 at 16:12
  • That's exactly what I do too! May 7, 2015 at 15:22
  • linuxjournal.com/content/… for more info on how to access the site after setting up the server
    – Tariq
    Aug 7, 2015 at 18:43
  • 1
    I know we're not supposed to "thank you" but that python command is awesome, thanks.
    – dmgig
    Nov 25, 2016 at 18:13
  • 1
    Try python -m http.server [<portNo>] for python 3 (stackoverflow.com/questions/17351016/…) and/or try py instead of python
    – Justin
    Mar 10, 2020 at 20:55
12

Chrome now only allows https:// servers to persistent list (version 39.xx)

https://support.google.com/chrome/answer/2693767?hl=en

Allow: This allows the site to access your camera and microphone at this time and a notification will appear confirming that you’ve granted access. If you select Allow on a "http" URL your preference will not be remembered in future visits. If you select Allow on a "https" URL, your preference will be remembered in future visits.

Maybe this link helps to set your local secure server if you are using Wamp. http://forum.wampserver.com/read.php?2,32986

Then you can add your local server to persistent allow list of chrome.

11

Step 1: Find your chrome preferences file: http://www.forensicswiki.org/wiki/Google_Chrome#Configuration

Step 2: Open it and Find the "profile" key

Step3: Under profile there will be a "content_settings" hash, that will have a "pattern_pairs" hash Add this to it:

  "*,*": {
    "media-stream-camera": 1
  }

Final example:

"profile": {
   ....
   "content_settings": {
      ....
      "pattern_pairs": {
         "*,*": {
            "media-stream-camera": 1
         },
         ....
      }
    }
}

WARNING: This will allow all websites access to your camera

7
  • On OSX, you may need to 'cd' to the preferences folder instead of looking for it in the finder. Jul 25, 2013 at 14:42
  • Did not work me!! I followed the exact procedure as above. Any suggestions?? Sep 29, 2013 at 5:16
  • Make sure you quit Chrome before modifying that file Oct 2, 2013 at 5:23
  • 1
    @anza maybe newer versions of chrome make this fix unworkable. I would try again making sure you completely close chrome before editing the file also dont but the ... in there thats just a place holder Dec 9, 2013 at 1:53
  • 1
    @ErikPetersen. Now any changes to the file are outdone after re-opening Chrome. Any idea how to make changes persist? Feb 6, 2014 at 4:13
0

Got this problem for days, only this helped:

Reinstall Chrome by removing configuration as well. And try not to sync all the extensions, as they may interfere.

sudo apt-get purge google-chrome-stable
rm -rf ~/.config/google-chrome

Then install from official.

0

One trick is to use mitmproxy. This works for both desktop and mobile.

Suppose I have a HTTP server on http://127.0.0.1:8082. I can use the command: mitmproxy --mode "reverse:http://127.0.0.1:8082".

Now, I can connect to my local server via HTTPS at https://127.0.0.1:8080 (mitmproxy uses port 8080 by default). Check the docs here to see how to install the root certificate, this way your device will not run into certificate errors.

-2

Another solution is to use iframe tag. Jest deploy your page on server (localhost or external) and include it in your local html. Example:

<iframe src="http://localhost/your_project/index.html"></iframe>
-2

Chrome on HTTP or any other port won't save the preference of Camara share choice.

To save the selection you will need to run on HTTPs, even if you don't have SSL certificate on localhost that fine. Just add https before the localhost url and it will ask you its unsafe, if you want to proceed add it as an exception under Advance options. Do that and then Chrome will save you camera sharing preference for this website. and won't ask you to select allow

-3

You can choose a different default permission setting and manage exceptions in Content settings.

  1. Click the Chrome menu Chrome menu on the browser toolbar.
  2. Select Settings.
  3. Click Show advanced settings.
  4. In the "Privacy" section, click Content settings.
  5. In the "Media" section:

* Ask me when a site requires access to my camera and microphone: Select this option if you want Chrome to alert you whenever a site requests access to your camera and microphone.

* Do not allow sites to access my camera and microphone: Select this option to automatically deny any site requests to access your camera and microphone.

Or click Manage exceptions to remove previously-granted permissions for specific sites. Source: https://support.google.com/chrome/answer/2696491?hl=en

P/D: the link you provided has an error. I can't access.

-5

Open localhost/webcam.swf then right click on the flash file then allow the webcam and tick remember that will add exception for localhost

Not the answer you're looking for? Browse other questions tagged or ask your own question.