Troubleshooting¶
This page groups common failures by symptom and then lists the checks and actions to take.
Even when several causes are possible, it is usually easiest to start from the closest symptom and work through the checks in order.
1. host.docker.internal connection issues¶
- Symptom: the mediators (
mediator-owner/mediator-buyer) or the frontend cannot reachhost.docker.internaland DNS resolution fails - Example log:
ConnectError("dns error", ... "failed to lookup address information: nodename nor servname provided, or not known") - Example (frontend, when
VITE_RPC_URLofiot-market-uiis set tohost.docker.internal):JsonRpcProvider failed to detect network ... (perhaps the URL is wrong or the node is not started)printed every second. If this appears with the defaulthttp://127.0.0.1:8545, the cause is not this one but a stopped node (check that thenpx hardhat nodeterminal is still running) - Cause:
host.docker.internalis a special hostname that Docker Desktop provides only inside containers. When you run a process outside a container (natively on the host OS) withcargo runornpm run dev, that name cannot be resolved.
Check¶
- Confirm the node itself is alive by running this on the host:
curl http://localhost:8545
If it returns {"jsonrpc":"2.0", ... "error": ... "Parse error: Unexpected end of JSON input"}, the node is reachable and healthy — this is the normal JSON-RPC response to a GET with an empty body, not an error.
Fix A — add a hosts entry (recommended)¶
As in step 0.5 of Quickstart (run the stack), add 127.0.0.1 host.docker.internal to your hosts file. Besides the settings files, host.docker.internal also appears in mediator-owner/src/main.rs (IPFS and PostgreSQL endpoints), mediator-buyer/src/main.rs, and the search API of iot-market-ui, so this is the most reliable fix.
Fix A' — edit the settings and sources¶
If you cannot change the hosts file, replace host.docker.internal with localhost in the files listed above. The settings file looks like this.
mediator-owner/settings/owner_1.yaml:
api_url: "http://localhost:3000"
rpc_url: "http://localhost:8545"
- Apply the same change to
mediator-buyer(it has no settings file; the endpoints are theAPI_URLandRPC_URLconstants inmediator-buyer/src/main.rs) and tosrc/routes/api/sql-query/+server.tsof the frontend (iot-market-ui), where the IPFS and PostgreSQL hosts are fixed tohost.docker.internal. The frontend RPC endpoint defaults tohttp://127.0.0.1:8545, so it needs no change. If you cannot find where the endpoint is set, grep the repository forhost.docker.internal. - Restart each process after editing.
Fix B — run inside containers¶
Run the mediators and frontend on the DevContainer / Docker side, where host.docker.internal resolves as intended. Choose this if you prefer not to change the settings.
2. IPFS container keeps restarting¶
- Symptom: running
docker compose psin theipfsdirectory shows theipfsSTATUS stuck atRestarting - Check: read the error with
docker compose logs ipfs - Action: if the stored data is broken, delete it together with the volumes with
docker compose down -v, then recreate withdocker compose up -d. The IPFS and PostgreSQL data are lost. Recreate theipfs_recordstable as described inipfs/README.md, then restartmediator-ownerso it registers the data again - Symptom:
docker compose up -dprintsBind for 0.0.0.0:8080 failed: port is already allocatedand IPFS does not start - Check: whether the publisher is running. Both use port 8080 (Port conflicts)
- Action: stop the publisher (
cd ~/program/Blockchain_IoT_Marketplace && docker compose -f infra/docker-compose.yml stop publisher), then rundocker compose up -dagain in theipfsdirectory. There is no need to delete any data
3. http://<HOST_IP>:5173/ not reachable from smartphone¶
- Symptom: the phone browser cannot open
http://<HOST_IP>:5173/(<HOST_IP>is the PC's LAN IP) - Check: the frontend was started with
npm run dev -- --host 0.0.0.0 --port 5173 - Check: both devices are on the same Wi-Fi network
- Check: the firewall allows
5173
4. Product does not appear¶
- Symptom: no merchandise is shown at http://localhost:5173
- The top page is a search screen. "Run Search" lists only items whose video metadata
mediator-ownerregistered in IPFS and PostgreSQL (theipfs_recordstable). Items created from event files and the 5 items registered by the deployment do not appear in the search. Openhttp://localhost:5173/merchandise/<item address>directly. - Check:
mediator-ownerwas started withcargo run -- settings/owner_1.yaml - Check: the
mediator-ownerterminal showsWatching raw_data/output for new event files. If not, update the course repository (git pull) and restart it - Check: when an event file is written,
Product deployed: 0x... for file ...is printed. The address shown is the one to use in the merchandise page URL
5. Purchase does not succeed¶
- Symptom: purchase does not succeed
- Check: MetaMask is connected with Account #2 (
0x3C44...). A purchase requires the buyer's public key to be registered in the PubKey contract. Keys are registered only for Account #2 (bymediator-buyerat startup) and Account #1 (bymediator-owner). A purchase from any other account reverts. If you buy an item registered bymediator-owner(aProduct deployeditem) with Account #1,mediator-owneralso acts as the buyer and saves the data tomediator-owner/downloads(nothing appears inmediator-buyer). The hands-on buys with Account #2 - Check: whether you already bought that item with the same account. One account can buy an item only once (a repeat purchase reverts). An item whose delivery is in progress (from the purchase until the data delivery completes) cannot be bought by any account. Use an item from a
Product deployed: 0x...line in themediator-ownerterminal that you have not bought yet, or restart the node and redeploy - Action: after restarting the local chain, clear stale MetaMask state and reconnect
6. Events are rejected with no_matching_consent¶
- Symptom: in the HA Demo Simulator (or similar), some datasets never appear in
/platform/ingest. Inaudit/logsthey showaction: deny/reason: no_matching_consent/subject_did: "unknown" -
Example log:
{"action":"deny","subject_did":"unknown","dataset_id":"home/event/possible_littering","purpose":"research","reason":"no_matching_consent", ...} -
Likely causes: the consent was not registered, or the consent has expired. If the
valid_toof a consent file (examples/ha_demo/consent_*.json) is in the past, the consent does not match at the current time and the event is denied even after registration. The bundled samples are valid until2030-12-31T23:59:59Z, but files whose dates you edited or files you wrote yourself can expire.
Check¶
- Read the audit log first (in zsh, quote the URL because
?is treated as a glob):
curl 'http://localhost:8080/audit/logs?limit=20'
- Open the consent file for the denied
dataset_idand confirm that today's date falls withinvalid_from–valid_to. Ifvalid_tois in the past, the consent has expired.
Fix¶
- Move
valid_toto a later date and re-register. Example that rewritesvalid_toin every file at once (macOSsedneeds-i ''):
cd ~/program/Blockchain_IoT_Marketplace
sed -i '' 's/"valid_to": "[^"]*"/"valid_to": "2035-12-31T23:59:59Z"/' examples/ha_demo/consent_*.json
- After editing, re-register the consents (confirm each response contains
"status":"stored"), re-send the events, then check/platform/ingestagain. - Existing
denyentries remain in the log as history. Always verify with a new event sent after the consent was registered.
7. Merchandise page returns 500 (iot-market-ui endpoint)¶
- Symptom: the list page (
/) opens, but an individual merchandise pagehttp://localhost:5173/merchandise/<address>returns HTTP 500 - Cause: the frontend (
iot-market-ui) reads its RPC and publisher endpoints fromiot-market-ui/.env.local. If that endpoint cannot reach the running Hardhat node (someone else's IP, a wrong port such as8546, or a host that is not up), the merchandise page fails to fetch data and returns 500. The list page has a timeout and still renders, so the failure first surfaces on the detail page.
Check and fix¶
- Open
iot-market-ui/.env.localand confirmVITE_RPC_URLpoints at the running node (defaulthttp://127.0.0.1:8545). If the file is missing, copy the template.
cd ~/program/Blockchain_IoT_Marketplace/iot-market-ui
cp .env.example .env.local
VITE_RPC_URL=http://127.0.0.1:8545
VITE_PUBLISHER_URL=http://127.0.0.1:8080
- For phone access, replace
127.0.0.1with the PC's LAN IP (e.g.http://192.168.1.20:8545). - Restart the frontend (
npm run dev) after editing. - Note: if a contract-address mismatch is suspected, stop and restart the Hardhat node (
npx hardhat node) and redeploy so the addresses align with the defaults. If they still differ, updateiot-market-ui/src/lib/contracts/IoTMarket.tsandPubKey.tsto the deployed addresses.
8. Cannot add the network to MetaMask¶
- Symptom: adding a
http://...:8545network to MetaMask (on a phone or PC) is rejected no matter how many times you try - Cause: MetaMask validates the network by connecting to the RPC when you add it. If the endpoint is unreachable, it is rejected. From a phone in particular, the default
npx hardhat nodeonly listens on127.0.0.1, so the phone cannot reach it.
Check and fix¶
- Restart the node exposed on the LAN.
# First stop the running node in Terminal 1 of the Quickstart with Ctrl+C
cd ~/program/Blockchain_IoT_Marketplace/iot-market
npx hardhat node --hostname 0.0.0.0
Restarting empties the chain. Redo step 2 (deploy) of the Quickstart (run the stack) and restart mediator-owner and mediator-buyer. If MetaMask shows a nonce error, reset the account (Settings → Advanced → Clear activity tab data).
- Use the PC's LAN IP for the RPC URL in MetaMask (e.g.
http://192.168.1.20:8545), with chain ID31337. - Confirm the PC firewall allows
8545and that the PC and phone are on the same Wi-Fi. - If you use the frontend from the phone, set
iot-market-ui/.env.localto the same LAN IP (see the previous item).
9. GET /platform/ingest returns 404¶
- Symptom:
curl http://localhost:8080/platform/ingestreturns{"detail":"platform_ingest_read_disabled"}(404) - Cause:
GET /platform/ingestis a demo-only API that returns every row without authentication, and it is disabled by default. -
Fix: restart the publisher with
PLATFORM_INGEST_READ_ENABLED=true.cd ~/program/Blockchain_IoT_Marketplace PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml up --build -d
10. Port conflicts¶
- Symptom: a process does not start and prints
address already in useorport is already allocated -
Check: find the process that holds the port (macOS / Linux).
lsof -i :8080 -
The main ports used in the course:
Port Used by Note 8080 IPFS gateway ( ipfs/docker-compose.yaml) and the publisher (infra/docker-compose.yml)Cannot run together. Before using the publisher, run docker compose downin theipfsdirectory8545 Hardhat node ( npx hardhat node)Do not start a second node 5173 Frontend ( iot-market-ui,npm run dev)Check that no other Vite dev server is running 8090 assistant ( assistant/ha-demo-phase3/assistant-llm/assistant-demoprofiles)The four profiles share the port, so start one at a time ( ha-demo-phase3also starts theassistantservice)18000 llm-mock ( llm-mock/assistant-demoprofiles)Stop the llm-mock/assistant-democontainer before running the hostuvicorn examples.phase3_llm_mock_server:app --port 1800011434 Ollama (installed directly on the PC) If the Ollama app is running in the background, another Ollama cannot start -
Fix: stop the conflicting process and start again.