diff --git a/src/addrdb.cpp b/src/addrdb.cpp
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -14,6 +14,8 @@
 #include <tinyformat.h>
 #include <util/system.h>
 
+#include <cstdint>
+
 namespace {
 
 template <typename Stream, typename Data>
@@ -36,7 +38,7 @@
 bool SerializeFileDB(const CChainParams &chainParams, const std::string &prefix,
                      const fs::path &path, const Data &data) {
     // Generate random temporary filename
-    unsigned short randv = 0;
+    uint16_t randv = 0;
     GetRandBytes((uint8_t *)&randv, sizeof(randv));
     std::string tmpfn = strprintf("%s.%04x", prefix, randv);
 
diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -590,7 +590,7 @@
 void StartMapPort();
 void InterruptMapPort();
 void StopMapPort();
-unsigned short GetListenPort();
+uint16_t GetListenPort();
 
 /**
  * Interface for message handling
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -46,6 +46,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <cstdint>
 #include <limits>
 #include <optional>
 #include <unordered_map>
@@ -123,8 +124,8 @@
     m_addr_fetches.push_back(strDest);
 }
 
-unsigned short GetListenPort() {
-    return (unsigned short)(gArgs.GetArg("-port", Params().GetDefaultPort()));
+uint16_t GetListenPort() {
+    return uint16_t(gArgs.GetArg("-port", Params().GetDefaultPort()));
 }
 
 // find 'best' local address for a particular peer
diff --git a/src/netaddress.h b/src/netaddress.h
--- a/src/netaddress.h
+++ b/src/netaddress.h
@@ -509,10 +509,10 @@
 
 public:
     CService();
-    CService(const CNetAddr &ip, unsigned short port);
-    CService(const struct in_addr &ipv4Addr, unsigned short port);
+    CService(const CNetAddr &ip, uint16_t port);
+    CService(const struct in_addr &ipv4Addr, uint16_t port);
     explicit CService(const struct sockaddr_in &addr);
-    unsigned short GetPort() const;
+    uint16_t GetPort() const;
     bool GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const;
     bool SetSockAddr(const struct sockaddr *paddr);
     friend bool operator==(const CService &a, const CService &b);
@@ -525,7 +525,7 @@
     std::string ToStringPort() const;
     std::string ToStringIPPort() const;
 
-    CService(const struct in6_addr &ipv6Addr, unsigned short port);
+    CService(const struct in6_addr &ipv6Addr, uint16_t port);
     explicit CService(const struct sockaddr_in6 &addr);
 
     SERIALIZE_METHODS(CService, obj) {
diff --git a/src/netaddress.cpp b/src/netaddress.cpp
--- a/src/netaddress.cpp
+++ b/src/netaddress.cpp
@@ -907,13 +907,13 @@
 
 CService::CService() : port(0) {}
 
-CService::CService(const CNetAddr &cip, unsigned short portIn)
+CService::CService(const CNetAddr &cip, uint16_t portIn)
     : CNetAddr(cip), port(portIn) {}
 
-CService::CService(const struct in_addr &ipv4Addr, unsigned short portIn)
+CService::CService(const struct in_addr &ipv4Addr, uint16_t portIn)
     : CNetAddr(ipv4Addr), port(portIn) {}
 
-CService::CService(const struct in6_addr &ipv6Addr, unsigned short portIn)
+CService::CService(const struct in6_addr &ipv6Addr, uint16_t portIn)
     : CNetAddr(ipv6Addr), port(portIn) {}
 
 CService::CService(const struct sockaddr_in &addr)
@@ -942,7 +942,7 @@
     }
 }
 
-unsigned short CService::GetPort() const {
+uint16_t CService::GetPort() const {
     return port;
 }
 
diff --git a/src/netbase.cpp b/src/netbase.cpp
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -12,6 +12,7 @@
 #include <util/system.h>
 
 #include <atomic>
+#include <cstdint>
 
 #ifndef WIN32
 #include <fcntl.h>
@@ -867,10 +868,10 @@
         static std::atomic_int counter(0);
         random_auth.username = random_auth.password =
             strprintf("%i", counter++);
-        if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) {
+        if (!Socks5(strDest, uint16_t(port), &random_auth, hSocket)) {
             return false;
         }
-    } else if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) {
+    } else if (!Socks5(strDest, uint16_t(port), 0, hSocket)) {
         return false;
     }
     return true;
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -11,6 +11,7 @@
 #include <QAbstractListModel>
 
 #include <cassert>
+#include <cstdint>
 
 namespace interfaces {
 class Node;
@@ -21,7 +22,7 @@
 QT_END_NAMESPACE
 
 extern const char *DEFAULT_GUI_PROXY_HOST;
-static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050;
+static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
 
 /**
  * Convert configured prune target MiB to displayed GB. Round up to avoid
diff --git a/src/seeder/bitcoin.h b/src/seeder/bitcoin.h
--- a/src/seeder/bitcoin.h
+++ b/src/seeder/bitcoin.h
@@ -9,10 +9,11 @@
 #include <protocol.h>
 #include <streams.h>
 
+#include <cstdint>
 #include <string>
 #include <vector>
 
-static inline unsigned short GetDefaultPort() {
+static inline uint16_t GetDefaultPort() {
     return Params().GetDefaultPort();
 }
 
diff --git a/src/seeder/test/p2p_messaging_tests.cpp b/src/seeder/test/p2p_messaging_tests.cpp
--- a/src/seeder/test/p2p_messaging_tests.cpp
+++ b/src/seeder/test/p2p_messaging_tests.cpp
@@ -14,6 +14,7 @@
 
 #include <boost/test/unit_test.hpp>
 
+#include <cstdint>
 #include <memory>
 #include <ostream>
 #include <string>
@@ -40,7 +41,7 @@
 };
 } // namespace
 
-static const unsigned short SERVICE_PORT = 18444;
+static const uint16_t SERVICE_PORT = 18444;
 
 struct SeederTestingSetup {
     SeederTestingSetup() {
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -23,6 +23,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <cstdint>
 #include <ios>
 #include <memory>
 #include <numeric>
@@ -94,10 +95,10 @@
 
 BOOST_AUTO_TEST_CASE(cnode_listen_port) {
     // test default
-    unsigned short port = GetListenPort();
+    uint16_t port = GetListenPort();
     BOOST_CHECK(port == Params().GetDefaultPort());
     // test set port
-    unsigned short altPort = 12345;
+    uint16_t altPort = 12345;
     BOOST_CHECK(gArgs.SoftSetArg("-port", ToString(altPort)));
     port = GetListenPort();
     BOOST_CHECK(port == altPort);