Mail Server Connection Failed With 'java.net.SocketException: Permission denied: connect.' Exception
Symptoms
Mail server configuration in Stash 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.stash.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.stash.internal.mail.MailServiceImpl.sendMessageSynchronously(MailServiceImpl.java:205) ~[stash-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 Stash's ability to connect to the mail server.
Last modified on Feb 26, 2016
Powered by Confluence and Scroll Viewport.