GeoIP / PECL strange issue with reading Region/City

Hello there,

First of all, thanks to the Piwik team for providing such a great solution for tracking and stats !

Here is my issue : i recently upgraded our dedicated server, and since then, i can’t make the GeoIP location to work except with the “GeoIP (php)” selection. PECL and its Geoip module are installed ok, and i reinstalled the latest GeoIPCity.dat (free one), but it seems that only the country is taken care of, no region or city is found via anything other than “GeoIP (php)”.
Both apache2 and cli conf.d/geoip.ini are correct (loading module and refering to the custom /var/www/piwik/misc directory), Geoip.dat renamed to GeoIPCity.dat as stated in the Wiki.
It worked fine on the previous server.

I’m on Debian Squeeze, updated (the old server too).

See screenshot for what i get in the Admin / Geolocation settings.

Thanks for any hint.

in PECL you should install the CITY geoip database, seems you only installed Country.

Thanks, but i actually installed the GeoLiteCity database, that’s why i don’t understand why it’s not recognized as that. Same behavior when i installed the Country database.
I’m using APC and a tmpfs for the /tmp directory, if that could matters (emptying them didn’t change anything, restarting apache after redownloading the city database neither).

Anyway, i’ll try redownloading the City database on next tuesday, and see what happens…

Sorry not sure myself, let us know if you find the cause!

All right, just tried again with the latest monthly GeoIPCity database, and same behavior. I really don’t get it…
I’m sticking with the GeoIP (php) parameter for now, but i would much prefer to use PECL as i kindda have high traffic on the tracked sites…
If anyone has an idea, it would be most welcomed.

Sorry to resurrect an older thread like this, but I seem to be having the same identical issue as described above. I installed GeoIP / PECL per the description for Ubuntu platforms, but I’m only getting Country Data with GeoIPCity.dat (obtained via – is that still right?).

What could I be doing wrong?

The correct download location is this:

Scroll down to the bottom of the page to find the various download links.

Thanks, canajun2eh, but even after replacing my GeoIPCity.dat file in my /var/www/misc directory with the .dat file from the above download you referenced, I’m still only getting Country data. When I go to the Geolocation Admin page, I get the following information next to the GeoIP (PECL) selector:

According to this provider, your current location is:

United States

Org: Unknown
ISP: Unknown

Note: The ‘geoip.custom_directory’ PHP ini option is set to ‘/var/www/misc’.

This GeoIP implementation has access to the following types of databases: Country.

Am I missing a trailing slash or something in my PHP.ini option? This is a pretty standard Digital Ocean Ubuntu 12.04 x64 droplet created just for this purpose, so it’s fresh. Any thoughts on what might be going on here?

FWIW, I also installed GeoIP (Apache) but only GeoIP (Php) - the remote calls to the API - works to generate City data.

Thanks for your help!

Not sure what’s going on, but if you find a problem in the docs let me know so I can update instructions :slight_smile:

I’m posting to this old thread as there doesn’t seem to be solution to this issue yet. I too am experiencing the same issue. If I copy the site to another webserver I get city and country via the PECL method. However, I don’t get city via the PECL method on my cPanel hosting account on GoDaddy.

Changing the PHP version doesn’t fix it either. I’ve tried PHP versions 5.3, 5.4 and 5.5 via the switch PHP version in cPanel. I’m curious is others who have posted in this thread are using cPanel.

What information is needed from me to help troublshoot this?


Hi guys,

I’ve had the same problem, downloaded the correct GeoIPCity.dat database, setting the “geoip.custom_directory” option correctly (which is also displayed correctly in Piwik).

After having done long research, I found out that City-level geo location with GeoIP (PECL) suddenly started working for me after

php_value geoip.custom_directory "/path/to/piwik/misc"

from my custom apache site config and rather setting

geoip.custom_directory = "/path/to/piwik/misc"

in php.ini instead.

Please don’t forget to restart apache afterwards!

So it seems there is a bug in the GeoIP (PECL) module / Piwik in not using the correct geo database when path is set via htaccess/apache site config.

Can someone confirm this?

Best Regards

I can confirm this! Thanks.

My server is already configured like that, and it didn’t solve the problem here. I’m using the latest Piwik.

I, too, am experiencing the same or a very similar issue.

The GeoIP (PECL) installation shows no errors, I have downloaded and renamed the database file, I have added the custom directory to the php.ini file, and when I visit the GeoIP page it correctly displays my city.

However, the real-time map shows no data for the report and the Visitor Location report has only country data.

Is there any log file or translation test we could perform that might give us more information? I cannot see any reason city data should not be appearing, yet it simply isn’t. There has to be some error or conflict that we’re missing.

Having same problem with PECL, it works well before during months… and now everything is wrong since recent updates…
I’ve uninstall PECL, re-install, check configuration, etc… and it’s not working.

Guyzs, did you found any solution to your problem? How did you solve?
Best regards

Unfortunately, I fixed this by provisioning a new server, and moving Piwik off my production web server as well as moving the database from my production database server to a local database on the new Piwik server.

While it’s not an actual fix, I could justify it in the fact that occasionally my web server was getting hammered with long queries on the Piwik end while users were trying to execute complex reports or return large amounts of data.

If data loss isn’t a concern, perhaps a completely fresh install will solve it, though it’s sort of the “nuclear option.”

Hi! I am having the issue described here, everything seems to install fine, but GeoIP PECL shows that it only has Country database available even though I have downloaded the .dat file into misc folder, set up the path in php.ini and everything in the dashboards points out that everything should be working.

Strangely enough, the default GeoIP (PHP) works fine and has cities available which is the one I am using, though I am wondering what might be wrong with PECL option.

Same problem here.

Just moved from regular VPS to Amazon AWS

GeoIP(php) works fine. GeoIP(PECL) does not get city info

any idea?

Even though I had geoip.custom_directoryset to piwik/misc folder I had to put the dat file in /usr/share/GeoIP/*.dat
Use find . -name "*GeoIP*" -print to find if you should put it in some other directory.