I am searching for comments ip address in D8 and I can't find where they are located in database. In D7 it was easy to find.

Is there a chance that D8 is not storing the commenters ip address? If it is not, how can I store it?

1 Answer 1


IP addresses are stored in the hostname field of the comment entity (which you'd usually find in the comment_field_data table).

This functionality is disabled by default, though (see Stop logging comment IP addresses by default). To enable it, it looks like you need to set the config manually, e.g.

   ->set('log_ip_addresses', TRUE)

After running that, IP addresses will start being logged in the hostname field.

  • Thanks for the quick reply. There are 12k comments in my blog so far. If I add in comment.install I guess that I would have to reinstall comment module and lose all comments? Or I can add it in some other place?
    – isin
    Commented Feb 3, 2020 at 22:01
  • 2
    @isin – Of course you don't add any custom code to a core or contrib module. You don't reinstall comments. You can execute the code from this answers from a custom module's hook_update_N or from the command line via drush ev "\Drupal::configFactory()->getEditable('comment.settings')->set('log_ip_addresses', TRUE)->save(TRUE);".
    – leymannx
    Commented Feb 4, 2020 at 8:08
  • Thank you Clive for the solution and leymannx for pointing out how to use the code. Started now a new installation and tried by using the drush ev... and it worked.
    – isin
    Commented Feb 4, 2020 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.