IMAP: NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)
The IMAP server rejected the login — wrong password, IMAP disabled, an app password required, or basic auth blocked.
[AUTHENTICATIONFAILED] Invalid credentials (Failure)imaplib.IMAP4.error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'NO [AUTHENTICATIONFAILED] Authentication failedIMAP login failed AUTHENTICATIONFAILEDLOGIN failed. Authentication failed Meaning
Mail clients and scripts (imaplib, Thunderbird) show this when credentials fail. For Gmail enable IMAP and use an app password or OAuth; for Microsoft 365 basic auth over IMAP is disabled, so OAuth is required. Dovecot servers log the real reason (auth failed, reason=...).
Common causes
- Wrong password/username
- IMAP access disabled for the account
- 2-Step Verification with normal password used
- Provider disabled basic auth (Microsoft 365)
- Account locked after repeated failures
⚡ Quick fix
- Enable IMAP in the mailbox settings
- Use an app password or switch to OAuth 2.0
- Check server logs:
grep -i "auth failed" /var/log/mail.log
Detailed fix by platform
Python
import imaplib; m = imaplib.IMAP4_SSL("imap.gmail.com"); m.login(user, app_password)raisesimaplib.IMAP4.error: [AUTHENTICATIONFAILED]on failure
How to diagnose
- User — Full address?
- Password — App password/OAuth?
- IMAP — Enabled for the account?
🔧 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
- 530 5.7.0 Authentication Required SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required
- 534 5.7.9 Application-specific password required SMTP: 534-5.7.9 Application-specific password required. Learn more at https://support.google.com/accounts/answer/185833
- 535 5.7.8 Username and Password not accepted SMTP: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials
Most viewed in Email / SMTP
Other ways to find it
Where this error sits
Origin: Network. 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 4 Nov 2026