Followers

Sunday, November 28, 2010

REASONS FOR: java.net.SocketException: Permission denied: connect

Hello friends,

Was trying to fetch response from a website, through the use of Socket class in a Java program.

Socket s1=new Socket("www.oracle.com",80);

Was getting the error:-

java.net.SocketException: Permission denied: connect

Solution:

The most probable reason for this, is that we are trying to access a port which is below 1023, which requires special privileges. In my case, I did not login as the administrator. Hence the error.


If I run the same lines of code , logged in as administrator, there will be no error.


Hope it helps,

Ashish Mishra

No comments:

Post a Comment