diff --git a/src/dhtrunner.cpp b/src/dhtrunner.cpp
index dd6ed1708ad632ae573d14612cf0b3e46e2814ea..e641e12c9ec11d107586a9d615882dfa1f35156b 100644
--- a/src/dhtrunner.cpp
+++ b/src/dhtrunner.cpp
@@ -1114,11 +1114,11 @@ DhtRunner::enableProxy(bool proxify)
                 },
                 config_.proxy_server, config_.push_node_id, logger_)
         );
-        dht_via_proxy_ = std::unique_ptr<SecureDht>(new SecureDht(std::move(dht_via_proxy), config_.dht_config));
 #ifdef OPENDHT_PUSH_NOTIFICATIONS
         if (not config_.push_token.empty())
-            dht_via_proxy_->setPushNotificationToken(config_.push_token);
+            dht_via_proxy->setPushNotificationToken(config_.push_token);
 #endif
+        dht_via_proxy_ = std::unique_ptr<SecureDht>(new SecureDht(std::move(dht_via_proxy), config_.dht_config));
         // add current listeners
         for (auto& l: listeners_)
             l.second.tokenProxyDht = dht_via_proxy_->listen(l.second.hash, l.second.gcb, l.second.f, l.second.w);