Get client IP from javascript or jquery


How can I get the client's real IP much from Javascript if possible.

This means that there is a direct connection, or through a proxy , or router or whatever, the real IP of the client computer always identifies me.

Implement this code in javascript. But it only works in some cases, and it is that it does not have a proxy, so it does not work for me personally, because it points to the proxy and not to the IP of my machine.


<!DOCTYPE html>
    <title>IP real</title>
     Mi IP es: <strong id="ipId"></strong>

    <script type="text/javascript">
        function get_ip(obj){
            document.getElementById('ipId').innerHTML = obj.ip;
    <script type="text/javascript" src=""></script>


Using JS , one option would be to use the API of a Web Service, for example Freegeoip , which accepts three response formats JSON XML CSV , the URL is specified as follows.{format}/{IP_or_hostname}
$.getJSON('//', function(data) {
<script src=""></script>

There are more alternatives, some are specified in this Answer

Scroll to Top