Trouble with local development on WSL2

Hi, I am new to the Internet Computer. Since I have a PC, I am running the Internet Computer on WSL2. I am currently following this guide for local development: Local development :: Internet Computer
I followed every step exactly, however when I run “dfx deploy” I get the error “Could not reach the server: error sending request for url ( error trying to connect: tcp connect error: Connection refused (os error 111)”. I don’t know what the source of this error is, but it prevents me from running any canister and I’m unable to run anything as basic as a “hello world” application. Any help whatsoever would be really appreciated! Thank you so much!

Do you also have dfx start running in another terminal? You’ll need both that and the terminal you’re deploying from, and both should be in the project directory. This might be the issue.

Thank you for your response! I followed the Local Development tutorial exactly, which included running dfx start in another terminal, so unfortunately that’s not the issue. Would there be any reason for dfx start or dfx deploy to error out in any way?

When you run dfx start, do you see any abnormality in the terminal log messages?

I believe when I tried using WSL2 and Ubuntu 20.04, I used

dfx start --background

to run dfx in the same terminal, and it worked.

The replica is quite verbose when it runs and will log lots of messages, most of them benign, which can be annoying when running in the same terminal. I think this is why using a second terminal is recommended.

If you could quote some of the output you see on running dfx start we might be able to offer more help. If you can’t quote the warnings because the forum doesn’t like the content (you see at 403 error), just post a screenshot instead.

This is what it looked like when I ran dfx start, and I screenshotted what appeared to be an abnormality. Is this unusual?

This is what it looked like when I ran dfx start --background. I’m fairly certain this is an error, but does this give any indication as to what is going wrong? Still can’t run dfx deploy.

What version of dfx are you using? is it 0.7.0 or 0.7.1?

When I ran dfx --version it says 0.6.26. Would I need to upgrade to 0.7.0? If so how would I do that?

DFX_VERSION=0.7.1 sh -ci "$(curl -fsSL"

You can run that. And let’s see if the error is still reproducible.

Thank you for your response. I updated to 0.7.1 and ran through the instructions again. When running dfx start I got the following:

and then when I ran dfx deploy I got this error:

which I think is the same error I got beforehand. Not entirely sure if anything changed in terms of the error?

What WSL image are you running? I believe that Ubuntu 20 is what is currently recommended for WSL.

Just checked, currently running Ubuntu 20.04.2 on WSL 2 .

Try to install sdk and create all your projects under the Linux home location. Once you start terminal do cd ~ and go from there.


Once I did cd ~ and ran everything again it worked! Thank you so much!! Everything seems to be working perfectly now


Apparently, having projects under your Windows home location (mounted drive) is not advisable.



That solution definitely works for me! @nerdoutcj Thanks for sharing! If you are using Windows you definitely should follow this advice! :star_struck: