diff --git a/src/init.cpp b/src/init.cpp index e4cd2f8ae0c..7fd8e221bdf 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1084,6 +1084,10 @@ bool AppInitParameterInteraction(const ArgsManager& args) if (user_rpc_max_connections < 1) { return InitError(Untranslated("-rpcmaxconnections must be greater than zero. Use -server=0 to disable HTTP.")); } + if (!args.GetBoolArg("-server", false)) { + num_rpc_bind = 0; + user_rpc_max_connections = 0; + } // Reserve enough FDs to account for the bare minimum, plus any manual connections, plus the bound interfaces. // Every element is an int >= 0 so summing in int64_t cannot overflow. diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py index 9277bc4fed8..283a67ec774 100755 --- a/test/functional/feature_init.py +++ b/test/functional/feature_init.py @@ -408,6 +408,16 @@ class InitTest(BitcoinTestFramework): match=ErrorMatch.PARTIAL_REGEX ) + # Start without the HTTP server to ensure that -rpcmaxconnections is ignored + with node.assert_debug_log( + expected_msgs = ["net thread start"], + unexpected_msgs = ["Initialized HTTP server"], + timeout = 10 + ): + node.start(extra_args=[f"-rpcmaxconnections={2**64}", "-server=0"]) + # No HTTP server, no RPC `stop` + node.kill_process() + def run_test(self): self.init_pid_test() self.init_stress_test_interrupt()