bcrypt error: Illegal arguments: undefined, string / data and salt arguments required / data and hash arguments required
bcrypt.compare/hash received undefined — the password field or stored hash wasn’t passed.
Illegal arguments: undefined, stringIllegal arguments: string, undefineddata and salt arguments requireddata and hash arguments required Meaning
The request body wasn’t parsed (missing express.json()), the field name differs (pass vs password), or the user query didn’t select the password column (select: false in Mongoose/Prisma omit).
Common causes
- Body not parsed (no JSON/body middleware)
- Field name mismatch
- Password hash not selected from the database
- User not found, hash undefined
⚡ Quick fix
- Add express.json() and validate input
- Explicitly select the password field (+password)
- Handle user-not-found before comparing
Detailed fix by platform
JavaScript
- `const user = await User.findOne({ email }).select("+password"); if (!user
- !password) return res.status(401).end(); const ok = await bcrypt.compare(password, user.password);`
How to diagnose
- Inputs — Values passed to compare
- Query — Password selected?
- Body — Parsed?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Authentication
- disallowed_useragent Google OAuth: Error 403: disallowed_useragent (sign-in from an embedded WebView)
- invalid_token invalid_token: The access token is invalid (JsonWebTokenError: invalid signature / jwt malformed)
- Access blocked: has not completed the Google verification process Google OAuth: Error 403: access_denied — The developer hasn't given you access to this app / has not completed the Google verification process
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026