com.android.volley.NoConnectionError: java.net.UnknownHostException for below Code. String url="https://www.user.url.in" JsonObjectRequest medStats = new JsonObjectRequest(Request.Method.PUT, url, object, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { Boolean success = response.getBoolean("success"); System.out.println("On Success" + success); // Toast.makeText(getApplicationContext(),""+success,Toast.LENGTH_SHORT).show(); //String message=response.getString("message"); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(context, "Error from server : " + error.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(context,Boolean.toString(isNetworkAvailable()),Toast.LENGTH_LONG).show(); String message = null; if (error instanceof NetworkError) { message = "Cannot connect to Internet...Please check your connection!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ServerError) { message = "The server could not be found. Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof AuthFailureError) { message = "Authentication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ParseError) { message = "Parsing error! Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof NoConnectionError) { message = "Communication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof TimeoutError) { message = "Connection TimeOut! Please check your internet connection."; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("x-access-token", token); return headers; } }; requestQueue.add(medStats); My Attempts: Check Manifest file:- 1. are added to checked url ,using Postman Internet is also working Logcat Details: 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151) 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: Caused by: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:470) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)

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

    com.android.volley.NoConnectionError: java.net.UnknownHostException

    Stack Overflow | 5 months ago | Ankur Khandelwal
    com.android.volley.NoConnectionError: java.net.UnknownHostException for below Code. String url="https://www.user.url.in" JsonObjectRequest medStats = new JsonObjectRequest(Request.Method.PUT, url, object, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { Boolean success = response.getBoolean("success"); System.out.println("On Success" + success); // Toast.makeText(getApplicationContext(),""+success,Toast.LENGTH_SHORT).show(); //String message=response.getString("message"); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(context, "Error from server : " + error.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(context,Boolean.toString(isNetworkAvailable()),Toast.LENGTH_LONG).show(); String message = null; if (error instanceof NetworkError) { message = "Cannot connect to Internet...Please check your connection!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ServerError) { message = "The server could not be found. Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof AuthFailureError) { message = "Authentication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ParseError) { message = "Parsing error! Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof NoConnectionError) { message = "Communication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof TimeoutError) { message = "Connection TimeOut! Please check your internet connection."; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("x-access-token", token); return headers; } }; requestQueue.add(medStats); My Attempts: Check Manifest file:- 1. are added to checked url ,using Postman Internet is also working Logcat Details: 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151) 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: Caused by: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:470) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)

    Root Cause Analysis

    1. com.android.volley.NoConnectionError

      java.net.UnknownHostException for below Code. String url="https://www.user.url.in" JsonObjectRequest medStats = new JsonObjectRequest(Request.Method.PUT, url, object, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { Boolean success = response.getBoolean("success"); System.out.println("On Success" + success); // Toast.makeText(getApplicationContext(),""+success,Toast.LENGTH_SHORT).show(); //String message=response.getString("message"); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(context, "Error from server : " + error.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(context,Boolean.toString(isNetworkAvailable()),Toast.LENGTH_LONG).show(); String message = null; if (error instanceof NetworkError) { message = "Cannot connect to Internet...Please check your connection!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ServerError) { message = "The server could not be found. Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof AuthFailureError) { message = "Authentication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof ParseError) { message = "Parsing error! Please try again after some time!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof NoConnectionError) { message = "Communication Error!!"; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } else if (error instanceof TimeoutError) { message = "Connection TimeOut! Please check your internet connection."; Toast.makeText(context,message,Toast.LENGTH_LONG).show(); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("x-access-token", token); return headers; } }; requestQueue.add(medStats); My Attempts: Check Manifest file:- 1. are added to checked url ,using Postman Internet is also working Logcat Details: 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151) 10-01 23:20:33.913 18856-18856/user.com.test2 W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: Caused by: java.net.UnknownHostException: Unable to resolve host "www.user.url.in": No address associated with hostname 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:470) 10-01 23:20:33.914 18856-18856/user.com.test2 W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)

      at java.net.InetAddress.getAllByName()
    2. Java RT
      InetAddress.getAllByName
      1. java.net.InetAddress.getAllByName(InetAddress.java:215)
      1 frame
    3. Android
      HttpEngine.sendRequest
      1. com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
      2. com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
      3. com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
      4. com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
      5. com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
      6. com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
      7. com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
      8. com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
      8 frames
    4. com.android.okhttp
      HttpURLConnectionImpl.execute
      1. com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
      1 frame