4.6 KiB
| title | aliases | tags | sources | created | updated | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Payload CMS — Troubleshooting Common Issues |
|
|
|
2026-05-15 | 2026-05-15 |
Dependency Mismatches
All payload and @payloadcms/* packages must be on exactly the same version and installed only once. Duplicate versions cause broken React context:
TypeError: Cannot destructure property 'config' of...
Diagnose duplicates
# pnpm
pnpm why @payloadcms/ui
# Any package manager
find node_modules -name package.json -exec grep -H '"name": "@payloadcms/ui"' {} \;
Check react and react-dom the same way — a second copy causes identical symptoms.
Note:
@payloadcms/uiships two bundles by design — dual paths in pnpm output are normal.
Correct import paths in Admin Panel
Inside Payload Admin UI, only import from:
@payloadcms/ui@payloadcms/ui/rsc@payloadcms/ui/shared
Deep imports like @payloadcms/ui/elements/Button are for your frontend only, outside of the Admin Panel.
Fix steps (pnpm)
- Pin exact versions — remove
^and~frompayload,@payloadcms/*,react,react-dom - Delete
node_modules pnpm install
If still broken:
pnpm store prune # clean global store
# Delete lockfile + node_modules, then:
pnpm install
pnpm dedupe
Last resort: add Webpack alias resolve.alias['react'] = path.resolve('./node_modules/react') until root cause is fixed.
Monorepos
Monorepo pitfall: package managers hoist dependencies differently per package, causing multiple instances.
- Pin
payload,@payloadcms/*,next,react,react-domat monorepo root - Delete
.next/,node_modules/, lockfile, then re-install - Watch for:
useUploadHandlers must be used within UploadHandlersProvider— next version mismatch
"Unauthorized" on Login
Unauthorized, you must be logged in to make this request
Means the auth cookie is not being set or accepted. Check:
- CORS — avoid
'*'; list explicit allowed domains - CSRF — if configured, whitelist your domain
- Cookie settings — if
domainis set, verify it's not misconfigured
Debug via Network tab
- Open DevTools → Network tab
- Perform login
- Inspect the login response — look for
Set-Cookieheader - Browser shows ⚠️ icon if cookie was rejected — hover to read the reason
--experimental-https HMR WebSocket Issue
Using --experimental-https breaks HMR WebSocket (ws:// vs wss://).
Fix — simple case:
USE_HTTPS=true
Fix — dynamic URL:
PAYLOAD_HMR_URL_OVERRIDE=wss://localhost:3000/_next/webpack-hmr
Database Password Encoding
Special characters in DB password cause silent connection failures:
Cannot read properties of undefined (reading 'searchParams')
Error: cannot connect to Postgres. Details: ...
Fix: URI-encode the password:
encodeURIComponent(yourPassword)
Set the encoded string in the DATABASE_URI connection string.
First verify the connection works outside Payload (e.g. Beekeeper Studio) to rule out network issues.
Key Takeaways
- Same version, one copy — any
@payloadcms/*orreactduplicate breaks context hooks with cryptic errors - pnpm dedupe + store prune — go-to when re-install alone doesn't fix it
- Monorepo root deps — install Payload packages at root level to avoid hoist conflicts
- Auth "Unauthorized" — 90% a cookie domain/CORS/CSRF misconfiguration; debug with Network tab
- HTTPS in dev — set
USE_HTTPS=trueorPAYLOAD_HMR_URL_OVERRIDEto fix HMR WebSocket protocol mismatch - DB special chars — always
encodeURIComponentpasswords with@,#,%etc. in connection strings
Related
- wiki/payloadcms/migration-troubleshooting — v2→v3 and v3→v4 upgrade issues
- wiki/payloadcms/installation — Node/Next.js requirements, create-payload-app
- wiki/payloadcms/authentication-cookies — CORS, CSRF, SameSite config detail
- wiki/payloadcms/database-overview — adapter selection, MongoDB vs Postgres
- wiki/payloadcms/production-deployment — security checklist, Docker, env config
- wiki/payloadcms/environment-vars —
.envsetup
Sources
raw/troubleshooting__troubleshooting.md- https://payloadcms.com/docs/troubleshooting/troubleshooting