# How to determine a location from IP address

**URL:** <https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308>\
**Category:** Rails\
**Created:** [June 8, 2007, 10:57am UTC](https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308 "2007-06-08T10:57:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [June 8, 2007, 10:57am UTC](https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308/1 "2007-06-08T10:57:47Z")

</div>

Hello,

I want to know how to determine a location from IP address in Rails.  
For example, 124.108.48.2 is from which country, using which ISP, Time  
Zone, lat and lng.  
Appreciate if have any ideas?

Thanks  
Chamnap

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [June 11, 2007, 6:19pm UTC](https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308/2 "2007-06-11T18:19:49Z")

</div>

> **[Industry leading IP Geolocation and Online Fraud Prevention | MaxMind](https://www.maxmind.com/en/home)**
>
> Customize content and comply with regulations using in-depth IP address data.
> Prevent fraud and chargebacks, manage cyber risk, and flag proxy users.

steve

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [June 12, 2007, 2:40am UTC](https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308/3 "2007-06-12T02:40:52Z")

</div>

Chamnap wrote:

> Hello,
> 
> I want to know how to determine a location from IP address in Rails.  
> For example, 124.108.48.2 is from which country, using which ISP, Time  
> Zone, lat and lng.  
> Appreciate if have any ideas?
> 
> Thanks  
> Chamnap

If you are looking for a free one you can use this:

www . hostip . info

(the spam catchers weren’t letting this through the normal way so I  
added the whitespace).

There are better ones out there that are commercial. The data is a  
little bit better so with the commercial ones if I remember so, you’ll  
have to weigh the difference between cost and accuracy.

To get Ruby on Rails to work with the site I mentioned, you will have to  
send your request in this format:

[http://api](http://api). hostip . info/?ip=12.215.42.19

(remove the whitespace)

and it will return your data in XML:

gml:nameSugar Grove, IL\</gml:name\>  
UNITED STATES  
US

so you’ll have to parse the returned XML via Ruby on Rails to get what  
you need.

I hope this gets you in the right direction. Unfortunately, in terms of  
exactly how to code it in Ruby on Rails, I am not sure.

---

<div class="post-metadata">

**Author:** ![chamnap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/779978/32.png) [@chamnap](https://www.ruby-forum.com/u/chamnap)\
**Post date:** [June 12, 2007, 2:52am UTC](https://www.ruby-forum.com/t/how-to-determine-a-location-from-ip-address/106308/4 "2007-06-12T02:52:08Z")

</div>

Thanks steve and mike.
