Gmail SMTP blocks you with 454 4.7.0 Too many login attempts
454 4.7.0 Too many login attempts, please try again laterShort answer
454 4.7.0 is a temporary block. Gmail saw repeated failed sign-ins from your app and told it to wait. Stop the sender, wait, and fix the reason sign-in fails (usually a normal password instead of an app password) before starting it again, or the block returns.
Fix it fast
1Find out which cause you have
Stop every process that sends through this account, then count how often your app tried to sign in. A queue worker or a cron job in a retry loop is the usual source.
grep -c -i -E "535|authentication|login" /var/log/myapp/mail.log2Match what you see, then jump to its fix
What does the error look like?
454 4.7.0 Too many login attempts, please try again laterSMTP Error: 454 4.7.0 Too many login attempts
Cause 1 of 2
Failed sign-ins were repeated until Gmail blocked them
1Check
Google lists 454 4.7.0 as too many sign-in attempts and says to try again later. The block is caused by repeated failures, so look at what the earlier errors said.
grep -E "535|534|530" /var/log/myapp/mail.log | tail -n 202Fix
Stop the loop and wait before the next try. Make the sender give up on an authentication error instead of retrying it, because retrying the same wrong credentials only prolongs the block.
import smtplib
try:
server.login(user, app_password)
except smtplib.SMTPAuthenticationError:
raise SystemExit("credentials rejected: fix them, do not retry")3Verify
After the wait, one login attempt succeeds and the log shows no repeat attempts.
grep -c "454" /var/log/myapp/mail.logConfirmed by knowledge.workspace.google.com
Cause 2 of 2
Every attempt fails because the password type is wrong
1Check
Google answers a plain password with 535 when the account needs an app password (it lists an application-specific password required message). Workspace accounts have no password sign-in for apps since 1 May 2025.
grep -E "535|5\.7\.8" /var/log/myapp/mail.log | head2Fix
Create an app password for the account (2-Step Verification must be on) or move to OAuth, then update the app and start it once.
MAIL_USERNAME=me@gmail.com
MAIL_PASSWORD=<app password>3Verify
One test send passes; see the 535 page if it does not.
python3 -c "import smtplib,ssl; s=smtplib.SMTP('smtp.gmail.com',587); s.starttls(context=ssl.create_default_context()); s.login('me@gmail.com','APP_PASSWORD'); print('ok')"Confirmed by support.google.com
How do I stop it coming back?
- Treat an authentication error as final in your mail code: log it once and alert, no automatic retry.
- Keep the volume inside the limit Google lists for smtp.gmail.com: 2,000 messages per day on Workspace.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Gmail SMTP login fails with 535 or 534 5.7.14
534-5.7.14 Please log in via your web browser and then try again.
Gmail turned your sign-in down.
3 causes, each with a fixDjango send_mail fails or hangs with an SSL error
smtplib.SMTPException raised from send_mail()
Django has two secure modes that must not be mixed: EMAIL_USE_TLS for explicit TLS (STARTTLS, usually port 587) and EMAIL_USE_SSL for implicit TLS (usually port 465).
4 causes, each with a fixGmail rejects your mail with 530 5.5.1 Authentication Required
530 5.5.1 Authentication Required
Gmail refuses to accept a message from a connection that has not signed in.
3 causes, each with a fixPython IMAP OAuth login to a shared mailbox in Microsoft 365 fails
imaplib.IMAP4.error: AUTHENTICATE failed.
Exchange Online accepts an OAuth token for IMAP only if the SASL user name is right and the token's identity has access to that mailbox.
4 causes, each with a fixPython says module smtplib has no attribute SMTP
print(smtplib.__file__) shows a path inside your own project
Python found a different smtplib than the standard one.
2 causes, each with a fixPython smtplib raises SMTPServerDisconnected: please run connect() first
smtplib.SMTPServerDisconnected: please run connect() first
smtplib raises SMTPServerDisconnected when you use an SMTP object that is not connected.
3 causes, each with a fix