fix: RPC server unreachable from outside Docker container

Open Beginner friendly
#141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
docker, python

Research direction

Start in main.py around line 659 and inspect the existing CLI argument handling, then review the Dockerfile CMD, HEALTHCHECK, and EXPOSE declarations. Reproduce the issue with the provided docker run and curl commands. Done means the RPC host is configurable, Docker binds it externally, port 8545 is declared, and the container remains healthy.

Written by the indexing model from the issue text.

Description

bug enhancement

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
Dominant language
Python
Stars
11
Forks
21
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StabilityNexus/MiniChain

All issues in StabilityNexus/MiniChain

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.