Skip to content

SES error: 421 Connection closed by server. Maximum message count per session reached.

0

Hello,

we're using AWS SES over SMTP for our self-hostet newsletter-tool in production (not sandbox).

Our current quota is 50,000 emails per 24h (max send-rate is 14 emails per second), which is totally enough. In average we send out 1000 emails per day, not at once but distributed over the day.

It was working good since the initial setup few days ago, but today the following message is showing up on every run of the send-cron-job: "Expected response code 250 but got code "421", with message "421 Connection closed by server. Maximum message count per session reached."

The send-queue holds currently 40 emails and the cron-job is trying every 30 minutes since 8 hours to send them out, but fails with the message above.

Does someone of you have an idea what is wrong here?

Maybe worth to mention: Yesterday we received the following email from Amazon: "Your AWS account ### has exceeded 85% of the usage limit for one or more AWS services with a Free Tier offer for the month of October. AmazonSES: 2740 Count, 3000 Usage Limit."

Can this have something to do with the error? Usually in the past - with other AWS services - it was like this: after a free tier was exceeded, the common billing starts. Is this different using SES? The SES dashboard shows a quota of 50,000 mails per 24h, so the free-tier should not have anything to do with this (We though this services is pay-as-you-go)....

Any help or information is highly appreciated!

asked a year ago300 views

3 Answers
5

Below the similar discussion you may referring to with some suggestions:

https://repost.aws/questions/QUw5qK9rBFSKqXvW5a-nAteg/amazon-ses-smtp-error-response-421-connection-closed-by-server-maximum-message-count-per-session-reached

  • Stop sending too many messages on a single SMTP connection. Reconnect after N messages where N is comfortably below the observed failure point. Common safe values used in the field are 250–500 messages per connection. Reconnect more often if you still see 421 errors.
  • Add retries with exponential backoff when you receive 421. On retry, open a fresh SMTP connection and resume sending the remaining messages.
  • Limit batch sizes and/or parallelism so no single process tries to send hundreds or thousands of messages on the same connection.
  • If possible, switch to the SES HTTP API (SendEmail or SendBulkTemplatedEmail) which avoids SMTP connection limits and is better suited for many sending workloads.
EXPERT

answered a year ago

AWS
EXPERT

reviewed a year ago

0

The error message "421 Connection closed by server. Maximum message count per session reached" indicates that you've hit a limit on the number of messages that can be sent in a single SMTP session, not your overall daily sending quota.

This is different from your daily sending quota of 50,000 emails or your maximum send rate of 14 emails per second. When using SMTP with Amazon SES, there's a limit to how many messages you can send in a single connection session before you need to disconnect and establish a new connection.

The free tier notification you received (2,740 out of 3,000 limit) is related to the AWS Free Tier for SES, which allows you to send 3,000 messages per month for free when sending from an Amazon EC2 instance. Once you exceed this limit, you'll be charged for additional messages, but the service will continue to work - this is not related to your current error.

To resolve your issue:

  1. Modify your newsletter tool's SMTP implementation to close and reestablish the SMTP connection after sending a batch of messages (typically after 50-100 messages)
  2. Ensure your application handles reconnection properly
  3. Consider implementing a backoff strategy if you encounter throttling errors

Your daily quota of 50,000 emails is still available, and your sending rate of 14 emails per second is still valid. This is purely a session-level limitation that requires you to manage your SMTP connections differently.
Sources
Errors related to the sending quotas for your Amazon SES account - Amazon Simple Email Service
Errors related to the sending quotas for your Amazon SES account - Amazon Simple Email Service
AWS SES Daily quota dashboard not refreshing | AWS re:Post
Amazon SES email sending errors - Amazon Simple Email Service

answered a year ago

AWS
EXPERT

reviewed a year ago

0

"...batch of messages of typically 50-100..." This is the information which is missing in the docs.

Before it was set to 490 per batch/queue-run, every 30 min. Now we set it to 90 per batch every 15 min. Lets see if this works better.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.