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)

Stack Overflow | DrProfesor | 6 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Sending information to server, java.net.SocketException: socket failed: EACCES (Permission denied)

    Stack Overflow | 6 months ago | DrProfesor
    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)
  2. 0

    HttpUrlConnection - android app - oauth2 authorization with spring web service

    Stack Overflow | 4 months ago | sebaaastian
    java.net.SocketException: socket failed: EACCES (Permission denied)
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    GitHub comment 1400#269891959

    GitHub | 2 months ago | jack16099
    java.net.SocketException: socket failed: EACCES (Permission denied)
  5. 0

    Consuming RESTful API developed in PHP and MySQL in Android using Retrofit

    Stack Overflow | 2 years ago | Megh Vidani
    java.net.SocketException: socket failed: EACCES (Permission denied) 08-27 12:59:02.865 822-856/? I/ActivityManager´╣Ľ Displayed com.example.android.taskapp/.BookListActivity: +541ms

  1. rp 1 times, last 2 months ago
  2. Indri Yunita 56 times, last 2 months ago
7 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. android.system.ErrnoException

    socket failed: EACCES (Permission denied)

    at libcore.io.Posix.socket()
  2. Android
    IoBridge.socket
    1. libcore.io.Posix.socket(Native Method)
    2. libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282)
    3. libcore.io.IoBridge.socket(IoBridge.java:608)
    3 frames
  3. Java RT
    Socket.setSoTimeout
    1. java.net.PlainSocketImpl.create(PlainSocketImpl.java:198)
    2. java.net.Socket.checkOpenAndCreate(Socket.java:689)
    3. java.net.Socket.setSoTimeout(Socket.java:543)
    3 frames
  4. Android
    HttpURLConnectionImpl.connect
    1. com.android.okhttp.Connection.connect(Connection.java:158)
    2. com.android.okhttp.Connection.connect(Connection.java:174)
    3. com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:316)
    4. com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:249)
    5. com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:397)
    6. com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:118)
    6 frames
  5. com.jake.locationapp
    MainActivity$MyLocationListener.onLocationChanged
    1. com.jake.locationapp.MainActivity.postData(MainActivity.java:84)
    2. com.jake.locationapp.MainActivity$MyLocationListener.onLocationChanged(MainActivity.java:197)
    2 frames
  6. Android Platform
    ActivityThread.main
    1. android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:285)
    2. android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:214)
    3. android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:230)
    4. android.os.Handler.dispatchMessage(Handler.java:102)
    5. android.os.Looper.loop(Looper.java:135)
    6. android.app.ActivityThread.main(ActivityThread.java:5430)
    6 frames
  7. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:372)
    2 frames
  8. Android
    ZygoteInit.main
    1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
    2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
    2 frames