Mail Server Connection Failed With 'java.net.SocketException: Permission denied: connect.' Exception
Symptoms
Mail server configuration in Bitbucket Server fails with the following exception:
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.
Last modified on Apr 6, 2016
Powered by Confluence and Scroll Viewport.