diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php
index 9dddcb73b..604c5bf2e 100644
--- a/library/attach_mod/displaying_torrent.php
+++ b/library/attach_mod/displaying_torrent.php
@@ -456,7 +456,7 @@ if ($tor_reged && $tor_info) {
'ROW_BGR' => $row_bgr,
'NAME' => ($peer['update_time']) ? $name : "$name",
'PEER_ID' => isset($peer['peer_id']) ? get_user_torrent_client($peer['peer_id']) : $lang['UNKNOWN'],
- 'COUNTRY' => render_flag(infoByIP($ip, $port)['countryCode'], false),
+ 'COUNTRY' => render_flag(infoByIP((!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']), $peer['port'])['countryCode'], false),
'COMPL_PRC' => $compl_perc,
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "$up_tot" : $up_tot,
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "$down_tot" : $down_tot,