Mail Server Connection Failed With 'java.net.SocketException: Permission denied: connect.' Exception

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Mail server configuration fails with the following exception in atlassian-fisheye-YYYY-MM-DD.log:

2014-12-02 10:44:29,856 ERROR [qtp1922315985-55427 -email-1417535069856] fisheye.mail Mailer-sendMessage - problem sending email
javax.mail.MessagingException: Could not connect to SMTP host: smtp.company.com, port: 25;
  nested exception is:
	java.net.SocketException: Permission denied: connect
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
	...
Caused by: java.net.SocketException: Permission denied: connect
	at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:579)
	at java.net.Socket.connect(Socket.java:528)
	at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
	... 161 more

Cause

  1. This is a known bug in Java 7, as per this post.
  2. This can be caused by anti-virus or firewall software blocking Java from connecting to the SMTP port.

Resolution

  1. Add -Djava.net.preferIPv4Stack=true to the FISHEYE_OPTS environment variable to help enable support for IPv4 on Java 7.
  2. Change the anti-virus or firewall software so that Java can connect to the SMTP server on the specified port.
Last modified on Nov 2, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.