Mail Server Connection Failed With 'java.net.SocketException: Permission denied: connect.' Exception
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
Mail server configuration in Bitbucket Server fails with the following exception:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2013-06-02 18:57:07,688 WARN [http-bio-7990-exec-7]
kaveh 1137x424x1 1rlae3i 49.14.35.22 "POST /admin/mail-server HTTP/1.1"
c.a.s.i.w.a.MailServerConfigurationController Failed to send a test
email message to <Email Recipient>
com.atlassian.bitbucket.exception.MailSendException: Message not sent: Mail sending failed
.
.
.
Caused by: org.springframework.mail.MailSendException: Mail server
connection failed; nested exception is javax.mail.MessagingException:
Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect. Failed messages:
javax.mail.MessagingException: Could not connect to SMTP host:
localhost, port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:400) ~[spring-context-support-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340) ~[spring-context-support-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355) ~[spring-context-support-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344) ~[spring-context-support-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at com.atlassian.bitbucket.internal.mail.MailServiceImpl.sendMessageSynchronously(MailServiceImpl.java:205) ~[bitbucket-service-impl-2.4.2.jar:na]
... 182 common frames omitted
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25
Cause
This is one of the known issues with Java 7, as per this post.
This can also be caused by any anti-virus or firewall software installed on the server.
Resolution
Use the
-Djava.net.preferIPv4Stack=true
JVM system property to help enable support for IPv4 on Java 7.Check that anti-virus and firewall software on the server is not blocking Bitbucket Server's ability to connect to the mail server.
Was this helpful?