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

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.