Unable to connect to AWS EC2 instance on port 25 (SMTP) for sending emails from Bitbucket Cloud Pipelines
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Unable to connect to AWS EC2 instance on port 25 (SMTP) for sending emails from Bitbucket Cloud Pipelines and it throws the below error:
1
2
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: domain.com, 25; timeout -1;
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
Cause
AWS blocks outbound traffic on port 25 (SMTP) of all EC2 instances and Lambda functions by default. Due to this restriction, the connection timed out occurs in the Bitbucket Pipelines.
Solution
Remove the default restriction on port 25 for the AWS EC2 instance.
→ Reference: How do I remove the restriction on port 25 from my Amazon EC2 instance or AWS Lambda function?
You may use a different port for connection other than port 25.
Updated on April 8, 2025
Was this helpful?
Still need help?
The Atlassian Community is here for you.