I’m developing a canister that integrates with the NNS (creating and managing neurons) and running into persistent PocketIC errors on my local testnet.
The errors look like: ``` ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:43963/instances) ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:46757/instances)
Environment:
- OS: Ubuntu on WSL2 (Windows)
-Ubuntu VERSION_ID=“24.04” - dfx – version 0.29.2
- node --version v22.13.1
-npm --version 10.9.
Working with local NNS neurons (created via governance canister)
Current Workaround:
Running `dfx start --clean` resolves the PocketIC errors, but this wipes all local state including the NNS neurons I’ve created for testing, forcing me to recreate them each time.
My Questions:
-
Are there known stable version combinations** (dfx, WSL, etc.) that minimize PocketIC initialization issues?
-
What’s the root cause of these PocketIC 400 errors, and can they be prevented without using `–clean`?
-
For WSL2 users specifically:** Are there any known configuration tweaks or workarounds for PocketIC stability?
What I’ve Tried:
- `pkill -f pocket-ic` before restart - `rm -rf ~/.cache/dfinity/pocketic`
- Checking for port conflicts (none found)
- `dfx stop` followed by `dfx start` (errors persist)
My testing workflow requires neurons to mature over several days, so losing state makes testing difficult.
Any guidance on 1: either preventing the PocketIC errors or, 2: preserving local NNS state would be greatly appreciated.
Note that I am a bit unexperienced with these types of testing, so the ideal solution should be as simplistic as possible. I read there is a testnet called playground, but things there are only persistent for 20 minutes so that would not allow me to conduct multi-day testing.
I think ideally, if there are known stable versions of these software when the issues wont appear over days, even if I start and stop dfx, that would be ideal.
ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:45257/instances)
ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:43753/instances)
ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:34709/instances)
ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:32857/instances)
ERROR: Failed to initialize PocketIC: HTTP status client error (400 Bad Request) for url (http://localhost:46125/instances)