InetAddress.getLocalHost(); public static String getServerIp() { InetAddress local = null; try { local = InetAddress.getLocalHost(); } catch ( UnknownHostException e ) { e.printStackTrace(); } if( local == null ) { return ""; } else { String ip = local.getHostAddress(); return ip; } }