java.net.SocketException: socket failed: EACCES (Permission denied) This is my method to post data to the server public void postData(String stuff){ //Create a new HTTPClient and Post Header URL url; HttpURLConnection con = null; status.setText("In post"); try{ url = new URL("http://myaddress/gpsin"); con = (HttpURLConnection)url.openConnection(); con.setDoOutput(true); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); con.connect(); //Send Request DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes((stuff)); wr.flush(); wr.close(); InputStream is; int response = con.getResponseCode(); if(response >= 200 && response<= 399){ //return success status.setText("Success!"); }else{ //return fail status.setText("Fail"); } } catch (Exception e){ e.printStackTrace(); status.setText("In catch"); }finally{ if(con!=null)con.disconnect(); } } Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jake.locationapp"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> LogCat: 09-09 12:43:33.308 11819-11819/com.jake.locationapp W/System.err: java.net.SocketException: socket failed: EACCES (Permission denied)

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Stack Overflow by DrProfesor
, 1 year ago
socket failed: EACCES (Permission denied) This is my method to post data to the server public void postData(String stuff){ //Create a new HTTPClient and Post Header URL url; HttpURLConnection con = null; status.setText("In post
via GitHub by danvinokour
, 1 year ago
socket failed: EMFILE (Too many open files)
via GitHub by jack16099
, 10 months ago
socket failed: EACCES (Permission denied)
java.net.SocketException: socket failed: EACCES (Permission denied) This is my method to post data to the server public void postData(String stuff){ //Create a new HTTPClient and Post Header URL url; HttpURLConnection con = null; status.setText("In post"); try{ url = new URL("http://myaddress/gpsin"); con = (HttpURLConnection)url.openConnection(); con.setDoOutput(true); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); con.connect(); //Send Request DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes((stuff)); wr.flush(); wr.close(); InputStream is; int response = con.getResponseCode(); if(response >= 200 && response<= 399){ //return success status.setText("Success!"); }else{ //return fail status.setText("Fail"); } } catch (Exception e){ e.printStackTrace(); status.setText("In catch"); }finally{ if(con!=null)con.disconnect(); } } Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jake.locationapp"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> LogCat: 09-09 12:43:33.308 11819-11819/com.jake.locationapp W/System.err: java.net.SocketException: socket failed: EACCES (Permission denied)
at libcore.io.Posix.socket(Native Method)
at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282)
at libcore.io.IoBridge.socket(IoBridge.java:608)
at java.net.PlainSocketImpl.create(PlainSocketImpl.java:198)
at java.net.Socket.checkOpenAndCreate(Socket.java:689)
at java.net.Socket.setSoTimeout(Socket.java:543)
at com.android.okhttp.Connection.connect(Connection.java:158)
at com.android.okhttp.Connection.connect(Connection.java:174)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:316)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:249)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:397)
at com.jake.locationapp.MainActivity.postData(MainActivity.java:84)
at com.jake.locationapp.MainActivity$MyLocationListener.onLocationChanged(MainActivity.java:197)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:285)
at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:214)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:230)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5430)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)

Users with the same issue

Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago

Know the solutions? Share your knowledge to help other developers to debug faster.