uptime RPC returns 0 on first invocation #34423

issue carloantinarella openend this issue on January 27, 2026
  1. carloantinarella commented at 8:26 pm on January 27, 2026: none

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    First time bitcoin-cli uptime is called, output is always zero.

    Expected behaviour

    Expected behavior should be first time invocation of bitcoin-cli uptime shows the actual bitcoind uptime.

    Steps to reproduce

    On Linux:

    1. ./build/bin/bitcoind -regtest -daemon
    2. sleep 10
    3. ./build/bin/bitcoin-cli -regtest uptime

    Output is zero, while non-zero is expected.

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    v30.99.0-c0e6556e4f51

    Operating system and version

    Ubuntu 22.04.5 LTS

    Machine specifications

    No response

  2. carloantinarella commented at 8:31 pm on January 27, 2026: none

    Probably caused by changes introduced in #34328

    I guess the function GetUptime() shall be called at least once in the startup phase to initialize the static variable g_startup_time. Also rpc_uptime.py could be updated with dedicated check.

    If ok, I would be happy to contribute with a PR for this.

  3. maflcko commented at 8:45 pm on January 27, 2026: member

    I guess the function GetUptime() shall be called at least once in the startup phase to initialize the static variable g_startup_time.

    Right, good catch. I think this was introduced by me in #34328 (review)

  4. maflcko added the label Bug on Jan 27, 2026
  5. maflcko added the label RPC/REST/ZMQ on Jan 27, 2026
  6. maflcko added this to the milestone 31.0 on Jan 27, 2026
  7. carloantinarella commented at 9:50 pm on January 28, 2026: none
    Thank you for the feedback. I did a test calling the function in AppInitMain, right before Step 4a code, and it works fine. Would it be a good solution? Is there already a plan for fixing this issue?
  8. l0rinc commented at 10:56 pm on January 28, 2026: contributor
    Thanks @carloantinarella, looks like we all misunderstood your original report. I pushed a fix to #34437, added you as coauthor. Thanks for testing it, keep it up!
  9. dergoegge commented at 10:32 am on January 29, 2026: member
    @carloantinarella out of curiosity what is your usecase for the uptime RPC? Any reason you prefer it over querying your OS for the uptime of the bitcoind process?
  10. carloantinarella commented at 7:06 pm on January 29, 2026: none
    No special needs, I just use it to check if the node is up and running. It’s os agnostic and returns plain number (good for quick scripting).

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-01 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me