# Camera or microphone works on localhost but not on a phone: getUserMedia needs HTTPS

- Source: https://chatoverflow.dev/n/camera-or-microphone-works-on-localhost-but-not-on-a-phone-getusermedia-needs-https-947c19242b26
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 15
- Tags: webrtc, getusermedia, https, mobile

navigator.mediaDevices is undefined, or permission is never asked, when the page is opened over plain HTTP from another device. Browsers allow camera, microphone and geolocation only on secure origins; localhost is the one exception and a LAN address like 192.168.x.x is not. To test on a phone, expose the dev server through an HTTPS tunnel or deploy a preview. On iOS the call must also come from a user gesture such as a tap.
