Address already in use (os error 48)


I’d like to report the error “Address already in use (os error 48)”, when dfx start, after a dfx stop.

I’m on macos and I guess I could’ve destroy the dfx process in the cli, but opened the activity monitor and cleared it there.

So, from my perspective the error should be a bit more verbose, for example, letting know which address that is, as in of course we know the context we are when developing but we can maybe see the port number that might be in use by a different program or event scan our local and figure out what’s using it.
Also, maybe a cli option to allow us to reset the dfx state in the context we are in to mitigate this sort of issues maybe…


I also had this a couple of times, but I closed down the terminal, waited a couple of seconds and opened a new terminal. The problem was solved always with this approach.

You can reset the replica state from the command line using dfx start --clean

This would be equivalent to deleting the .dfx folder in your project directory.

1 Like

@PeterRusznak I like the fact that you closed the terminal and waited a couple of seconds AKA in UK terms, went out for a cup of tea :smiley:

Yeh, do you know how it happened? I tried to replicate it, but couldn’t, so it’s one of those things…

Heya @Ori , that’s great tip! Thank you very much!

dfx start --clean
1 Like

I am not entirely sure when this happens but maybe when I stop and try to re-start immediately. Just a guess.

That’s actually a good point, I did the exact same, and quite quick. So, there might be some process in the process that should complete before we can interact with it which is terminating while processing and we’re basically interrupting…

Process in the process of processing :sweat_smile: