diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index 08dc5ed..c3fdefe 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -145,7 +145,12 @@ public function preSave(EntityStorageInterface $storage) {
       }
       // Add the values which aren't passed into the function.
       $this->setThread($thread);
-      $this->setHostname(\Drupal::request()->getClientIP());
+      // Check if the hostname is set.
+      $host_name = $this->getHostname();
+      // If the hostname is not explicitly set, set it to the client IP.
+      if (empty($host_name)) {
+        $this->setHostname(\Drupal::request()->getClientIP());
+      }
     }
   }
 
