Grocy: Barcode Scanner Not Working — Fix
The Problem
You click the barcode scan button in Grocy and either the camera popup appears but never requests camera access, the camera doesn’t open at all, or scanned barcodes aren’t recognized. This affects product lookup, inventory management, and shopping list workflows.
Quick Diagnosis
| Symptom | Likely Cause | Jump To |
|---|---|---|
| Camera popup opens but no permission prompt | HTTPS not configured | Method 1 |
| Camera opens but won’t scan QR codes | Grocy version too old | Method 2 |
| Special characters corrupted after scan | Encoding bug in v4.4.0 | Method 2 |
| Barcode button does nothing | Browser permissions denied | Method 3 |
| Using Home Assistant add-on | Known incompatibility | Method 4 |
| Camera works but scanning is unreliable | Hardware limitation | Method 5 |
The Cause
Grocy’s camera-based barcode scanning uses the browser’s MediaStream API, which modern browsers restrict to secure contexts (HTTPS). If you’re accessing Grocy over plain HTTP, the browser silently blocks camera access without showing an error. Additionally, Grocy versions before v4.5.0 used the older Quagga2 library which only supported linear barcodes (Code128, EAN) — QR codes and DataMatrix codes were not recognized.
The Fix
Method 1: Enable HTTPS
This is the most common cause. Browsers require HTTPS for camera access — no exceptions.
Check if this is your issue:
- Look at your Grocy URL in the browser address bar
- If it starts with
http://(nothttps://), this is your problem - Open browser developer tools (F12) and check the console for
enumerateDevices is not definedor similar media API errors
Fix with Nginx Proxy Manager:
If you’re already running Nginx Proxy Manager, add a proxy host:
- Go to Hosts → Proxy Hosts → Add Proxy Host
- Set Domain:
grocy.yourdomain.com - Forward to:
http://[grocy-ip]:8080 - SSL tab: Request a new SSL certificate, enable Force SSL
Fix with Caddy:
grocy.yourdomain.com {
reverse_proxy localhost:8080
}
Caddy automatically provisions SSL certificates via Let’s Encrypt.
Fix with a self-signed certificate (local network only):
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes \
-subj "/CN=grocy.local"
Then configure your reverse proxy to use these certificates. Note: browsers will show a security warning for self-signed certs, but camera access will work after accepting the warning.
See Reverse Proxy Setup for detailed instructions.
Method 2: Upgrade to v4.5.0+
Grocy v4.5.0 replaced the Quagga2 barcode library with ZXing, adding support for QR codes and DataMatrix codes. It also fixed a character encoding bug in the Open Food Facts plugin.
What v4.5.0 fixes:
- QR code scanning (previously unsupported)
- DataMatrix code scanning (previously unsupported)
- Special characters corrupted when importing from Open Food Facts (e.g., “à” appearing as ”?”)
Upgrade your Docker container:
# Check current version
docker exec grocy cat /var/www/public/version.json
# Update to v4.5.0+
docker compose pull
docker compose up -d
If using the LinuxServer.io image:
services:
grocy:
image: lscr.io/linuxserver/grocy:4.5.0
# ... rest of config
Method 3: Fix Browser Permissions
If you’ve previously denied camera access, the browser remembers that decision.
Chrome/Edge:
- Click the lock icon (or tune icon) in the address bar
- Find “Camera” in the permissions list
- Change from “Block” to “Allow”
- Reload the page
Firefox:
- Click the shield icon in the address bar
- Click “Connection secure” → “More information”
- Go to the Permissions tab
- Find “Use the Camera” and set to “Allow”
- Reload the page
Safari:
- Go to Safari → Settings → Websites → Camera
- Find your Grocy domain
- Set to “Allow”
Test camera access independently:
Open your browser’s developer console (F12) and run:
navigator.mediaDevices.enumerateDevices()
.then(devices => console.log(devices))
.catch(err => console.error(err));
If this returns an error, your browser or device doesn’t support camera access in this context.
Method 4: Home Assistant Workaround
Grocy running as a Home Assistant add-on cannot use camera barcode scanning. Home Assistant’s iframe sandboxing blocks the MediaStream API — this is a known, unfixable limitation of the add-on architecture.
Workarounds:
- Use a USB barcode scanner (recommended) — works regardless of browser restrictions
- Access Grocy directly — bypass Home Assistant’s iframe by navigating to the Grocy URL directly (e.g.,
https://homeassistant.local:9192) - Run Grocy as a standalone Docker container instead of a Home Assistant add-on
Method 5: Use a USB Barcode Scanner
Camera-based barcode scanning is inherently unreliable. The Grocy maintainer recommends USB hardware scanners, stating they “work 1000% better, faster, under any lighting condition and from any angle.”
USB barcode scanners emulate keyboard input — they type the barcode value and press Enter. No driver installation needed, no HTTPS requirement, no browser permissions.
Recommended setup:
- Get any USB barcode scanner ($15-30 on Amazon)
- Plug it into the device running your browser
- Click into any barcode field in Grocy
- Scan — the barcode value is typed automatically
For mobile scanning: Use a Bluetooth barcode scanner paired to your phone or tablet. These work identically to USB scanners but wirelessly.
| Method | Cost | Reliability | Speed | HTTPS Required |
|---|---|---|---|---|
| Camera (phone/webcam) | $0 | Low-Medium | Slow | Yes |
| USB barcode scanner | $15-30 | Very High | Instant | No |
| Bluetooth scanner | $25-50 | Very High | Instant | No |
Prevention
- Always use HTTPS — set up a reverse proxy with SSL from the start
- Keep Grocy updated — run v4.5.0+ for the best scanning experience
- Invest in a USB scanner if you’ll be scanning regularly — the time savings pay for the device within a week of use
- Test camera access after any browser update — browser security policies change and can revoke previously granted permissions
Related
Get self-hosting tips in your inbox
Get the Docker Compose configs, hardware picks, and setup shortcuts we don't put in articles. Weekly. No spam.
Comments