Getting error when trying to run 'dfx start --clean --background'

getting error while running dfx start --clean --background

Running dfx start for version 0.15.1
Using the default definition for the 'local' shared network because /home/akash/.config/dfx/networks.json does not exist.
  Version v0.15.1 installed successfully.
thread 'main' panicked at 'Error creating db for artifacts: Corrupted', rs/artifact_pool/src/lmdb_pool.rs:351:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'replica-actor' panicked at 'called `Result::unwrap()` on an `Err` value: Cannot start the replica: timed out', src/dfx/src/actors/replica.rs:393:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)

also tried reinstalling dfx, but still the same error
tried with the latest dfx version too, but the error persist

Try upgrading to the latest version. 0.15 is quite far behind 0.24

still getting the same error

Running dfx start for version 0.24.1
Using the default configuration for the local shared network.
thread 'main' panicked at rs/artifact_pool/src/lmdb_pool.rs:446:39:
Error creating db for artifacts: Corrupted
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: An error happened during communication with the replica: error sending request for url (http://127.0.0.1:4943/api/v2/status)
Caused by: error sending request for url (http://127.0.0.1:4943/api/v2/status)
Caused by: client error (Connect)
Caused by: tcp connect error: Connection refused (os error 111)
Caused by: Connection refused (os error 111)

Are you running this on WSL? The replica is not built for WSL and regularly doesn’t work at all there.

Can you also try --pocketic? That uses PocketIC instead of the real replica

Yes, I’m running this on WSL on Windows.

I tried using --pocketic, but it also throws an error:

ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:63163/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 111): Connection refused (os error 111)

Is there any other way to run this on Windows? Any alternative solutions or workarounds.

Not looking great TBH. If you are on WSL1 you can try it on WSL2 as well. That has much better chances at working.

@mraszyk do you know if PocketIC has any chance at working on WSL2?

WSL has a few broken APIs that otherwise are available on *nix. Some people occasionally get dfx start running in a docker container, but I don’t know of a currently working example.

Yes, I’ve successfully tested PocketIC to work in WSLv2.

1 Like

Hey, I tried to run the command in Linux based system, but still running into errors

┌──(kali㉿kali)-[~/Documents/hello]
└─$ dfx start --clean --background           
Running dfx start for version 0.24.1
Using the default configuration for the local shared network.
Error: An error happened during communication with the replica: error sending request for url (http://127.0.0.1:4943/api/v2/status)
Caused by: error sending request for url (http://127.0.0.1:4943/api/v2/status)
Caused by: client error (Connect)
Caused by: tcp connect error: Connection refused (os error 111)
Caused by: Connection refused (os error 111)

Could you try with a clean Ubuntu instance instead of Kali ?

I’m trying on ubuntu now, it is running i guess but when i try to open the url http://127.0.0.1:4943/ it’s showing canister_id_not_found

here;s the terminal

mrsky@mrsky-VirtualBox:~/Documents/hello$ dfx start --clean --background
Running dfx start for version 0.24.1
Using the default configuration for the local shared network.
Initialized replica.
Initialized HTTP gateway.
Replica API running on 127.0.0.1:4943

mrsky@mrsky-VirtualBox:~/Documents/hello$ dfx canister create --all
Creating canister mini-icp-backend...
Creating a wallet canister on the local network.
The wallet canister on the "local" network for user "default" is "bnz7o-iuaaa-aaaaa-qaaaa-cai"
mini-icp-backend canister created with canister id: bkyz2-fmaaa-aaaaa-qaaaq-cai
Creating canister mini-icp-frontend...
mini-icp-frontend canister created with canister id: bd3sg-teaaa-aaaaa-qaaba-cai

Makes sense. Try to open <frontend canister id>.localhost:4943 (as dfx deploy prints at the end). Then you should see something

@Severin
I encountered the same issue on macOS. It started working inexplicably once, but after shutting down the replica and restarting it the next day, the problem reappeared. I tried using --clean, --pocketic, and restarting the computer, but none of them worked.

➜  ~ dfx start --clean
Running dfx start for version 0.24.3
Using shared network 'local' defined in /Users/zensh/.config/dfx/networks.json
Initialized replica.
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:49918/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:49921/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:49923/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:49925/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)

@Severin
I’ve been troubled by this issue for a long time, which has kept me from starting development for a canister locally.

➜  ~ dfx start -v
Running dfx start for version 0.25.0
There is no project-specific network 'local' because there is no project (no dfx.json).
Using shared network 'local' defined in /Users/zensh/.config/dfx/networks.json
Local server configuration:
  bind address: [::1]:4943 (default: 127.0.0.1:4943)
  bitcoin: disabled
  canister http: enabled
    log level: Error
  replica:
    subnet type: Application
    log level: Error
  data directory: /Users/zensh/Library/Application Support/org.dfinity.dfx/network/local
  scope: shared

Starting canister http adapter...
canister http adapter ready
Starting replica...
Waiting for replica to report healthy status
Initialized replica.
Dashboard: http://localhost:61936/_/dashboard
replica ready on http://localhost:61936, so re/starting HTTP gateway
Starting pocket-ic gateway...
⠂ Starting local network...                                                                                                                                                                                         2025-03-05T01:30:52.322144Z  INFO pocket_ic_server: The PocketIC server is listening on port 61945
Configuring PocketIC gateway
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:61945/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
Starting pocket-ic gateway...
⠄ Starting local network...                                                                                                                                                                                         2025-03-05T01:30:52.840154Z  INFO pocket_ic_server: The PocketIC server is listening on port 61947
Configuring PocketIC gateway
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:61947/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
Starting pocket-ic gateway...
⠤ Starting local network...                                                                                                                                                                                         2025-03-05T01:30:53.306094Z  INFO pocket_ic_server: The PocketIC server is listening on port 61953
Configuring PocketIC gateway
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:61953/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
Starting pocket-ic gateway...
⠒ Starting local network...                                                                                                                                                                                         2025-03-05T01:30:53.764304Z  INFO pocket_ic_server: The PocketIC server is listening on port 61955
Configuring PocketIC gateway
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:61955/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
Starting pocket-ic gateway...
⠈ Starting local network...                                                                                                                                                                                         2025-03-05T01:30:54.230417Z  INFO pocket_ic_server: The PocketIC server is listening on port 61961
⠁ Starting local network...                                                                                                                                                                                         Stopping canister http adapter...
Got signal to stop. Killing ic-https-outcalls-adapter process...
Stopped.
Stopping the replica...
stopping replica
Got signal to stop. Killing replica process...
Stopped.
Stopping HTTP gateway...
Configuring PocketIC gateway
ERROR: Failed to initialize HTTP gateway: error sending request for url (http://localhost:61961/http_gateway): client error (Connect): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)
Got signal to stop.
Stopped.
All local network processes stopped

@mraszyk any ideas about gateway issues?

I’m not aware of any outstanding HTTP gateway issues. What caught my attention though is the override bind address: [::1]:4943 (default: 127.0.0.1:4943): could you please try with ipv4 (127.0.0.1) instead?

1 Like

Resolved, thank you very much!
The localhost entry in /etc/hosts was resolving to ::1. Changing it to 127.0.0.1 fixed the issue.