Error: access denied("java.net.SocketPermission""xxx.xx.xxx.xxx:xxxx""connect,resolve)

Problem:



Solution:

  1. Close your browser

  2. Go to C:\Program Files (x86)\Java\jre1.8.0_151\lib\security    (The path can differ based on your java version)

   3. Take a backup of java.policy

   4. Add the line in red color in the file with the IP and port you see in the error (Replace  xxx.xx.xxx.xxx:xxxx with the IP and port in the error). If you cannot add the line in existing file then you can copy the java.policy file to some other location, edit it and copy back/replace it.

 

// Standard extensions get all permissions by default

 

grant codeBase "file:${{java.ext.dirs}}/*" {

        permission java.security.AllPermission;

};

 

// default permissions granted to all domains

 

grant {

        // Allows any thread to stop itself using the java.lang.Thread.stop()

        // method that takes no argument.

        // Note that this permission is granted by default only to remain

        // backwards compatible.

        // It is strongly recommended that you either remove this permission

        // from this policy file or further restrict it to code sources

        // that you specify, because Thread.stop() is potentially unsafe.

        // See the API specification of java.lang.Thread.stop() for more

        // information.

        permission java.lang.RuntimePermission "stopThread";

 

        // allows anyone to listen on dynamic ports

        permission java.net.SocketPermission "localhost:0", "listen";

 

        // "standard" properies that can be read by anyone

 

        permission java.util.PropertyPermission "java.version", "read";

        permission java.util.PropertyPermission "java.vendor", "read";

        permission java.util.PropertyPermission "java.vendor.url", "read";

        permission java.util.PropertyPermission "java.class.version", "read";

        permission java.util.PropertyPermission "os.name", "read";

        permission java.util.PropertyPermission "os.version", "read";

        permission java.util.PropertyPermission "os.arch", "read";

        permission java.util.PropertyPermission "file.separator", "read";

        permission java.util.PropertyPermission "path.separator", "read";

        permission java.util.PropertyPermission "line.separator", "read";

 

        permission java.util.PropertyPermission "java.specification.version", "read";

        permission java.util.PropertyPermission "java.specification.vendor", "read";

        permission java.util.PropertyPermission "java.specification.name", "read";

 

        permission java.util.PropertyPermission "java.vm.specification.version", "read";

        permission java.util.PropertyPermission "java.vm.specification.vendor", "read";

        permission java.util.PropertyPermission "java.vm.specification.name", "read";

        permission java.util.PropertyPermission "java.vm.version", "read";

        permission java.util.PropertyPermission "java.vm.vendor", "read";

        permission java.util.PropertyPermission "java.vm.name", "read";

permission java.net.SocketPermission "xxx.xx.xxx.xxx:xxxx","connect,accept,resolve";

};

 5. Add the URL that you are using in the browser to the file exception.sites in location C:\Windows\Sun\Java\Deployment (If the URL  is blocking by java security in your browser)

 6. Start your browser and try the URL, it should work now.



Comments