Skip to content

fix: RPC server unreachable from outside Docker container #141

Description

@g-k-s-03

Problem

The RPC server is hardcoded to 127.0.0.1 in main.py:659:

await rpc_server.start(host="127.0.0.1", port=rpc_port)

The Dockerfile correctly passes --host 0.0.0.0 for the P2P
server via CMD, but the RPC server ignores the --host flag
entirely — it is hardcoded in Python code.

This creates a contradiction:

Config Result
P2P server --host 0.0.0.0 via CMD reachable from outside
RPC server hardcoded 127.0.0.1 connection refused
HEALTHCHECK hits 127.0.0.1:8545 passes inside container
EXPOSE only declares 9000 8545 not declared

Steps to Reproduce

docker run -p 8545:8545 -p 9000:9000 ghcr.io/stabilitynexus/minichain
curl http://localhost:8545
# connection refused

Expected Behaviour

RPC server should be reachable from outside the container
when -p 8545:8545 is passed.

Proposed Fix

Three small changes:

  1. Add --rpc-host CLI argument to main.py (default
    127.0.0.1 for bare metal safety)
  2. Use args.rpc_host instead of hardcoded "127.0.0.1"
    on line 659
  3. Pass --rpc-host 0.0.0.0 in Dockerfile CMD and add
    EXPOSE 8545

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions