diff --git a/src/ringdht/p2p.cpp b/src/ringdht/p2p.cpp
index 1d8918b6c24c5d1c0e7cbfb668e65d260e343822..9d85531c4ea3ea81ab6dcb5658d68628863b7ecd 100644
--- a/src/ringdht/p2p.cpp
+++ b/src/ringdht/p2p.cpp
@@ -699,12 +699,11 @@ DhtPeerConnector::closeConnection(const std::string& peer_id, const DRing::DataT
     // will be determined via the pair (dev_h, tid).
     // That's why we need to call CANCEL for the peer_h and each dev_h.
     const auto peer_h = dht::InfoHash(peer_id);
-    auto addresses = pimpl_->account.publicAddresses();
 
     pimpl_->ctrl << makeMsg<CtrlMsgType::CANCEL>(peer_h, tid);
     pimpl_->account.forEachDevice(
         peer_h,
-        [this, addresses, tid](const std::shared_ptr<RingAccount>& account,
+        [this, tid](const std::shared_ptr<RingAccount>& account,
                           const dht::InfoHash& dev_h) {
             if (dev_h == account->dht().getId()) {
                 RING_ERR() << account << "[CNX] no connection to yourself, bad person!";