Error: Socket Exception while trying to access kmd

Goodmorning everyone,
I am developing an Algorand Wallet on a Flutter mobile application in dart.
Right now I’m trying to connect to the kmd service of a node in order to get more addresses for a wallet from the same seedphrease.
The node has started and kmd also but when I try to use the algorithm library method.kmd I get an error like:

DioError [DioErrorType.other]: SocketException: OS Error: Connection refused, errno = 111, address =, port = 44824
# 0

below I attach the code that reports this error every time the algorithm.kmd.createWallet () method is presented :

Future<String> createNewAddress() async {

    final walletRequest = (CreateWalletRequestBuilder()
      ..walletName = 'wallet'
      ..walletPassword = 'test'
      ..walletDriverName = '')

    final handleTokenRequest = (InitWalletHandleTokenRequestBuilder()
        ..walletId = 'wallet'
        ..walletPassword = 'test')

    final keyRequest = (GenerateKeyRequestBuilder()
      ..displayMnemonic = true
      ..walletHandleToken = 'aa')

      final response = await algorand.kmd.createWallet(createWalletRequest: walletRequest);

      final handleToken = await algorand.kmd.initWalletHandleToken(initializeWalletHandleTokenRequest: handleTokenRequest);

      final address = await algorand.kmd.generateKey(generateKeyRequest: keyRequest);

      return address.toString();

would anyone know how to help me and explain why and how to fix this error? thanks a lot !

This is a duplicate of Connection refused, errno = 111, address = localhost, port = 57838 #0

As explained, doing that is very dangerous from a security point of view.
If you want to derive multiple accounts from the same passphrase, you need to implement the logic in the wallet itself and not rely on an external kmd which opens to a lot of attacks.

If you absolutely want kmd, the issue is most likely that:

  • the port is incorrect
  • or the address is incorrect. Importantly, means that kmd must be running on the same computer as the computer running the flutter app. iOS/Andoid simulator may be considered a different computer. And running the wallet as an iPhone/Android app on a real phone will never work with because is the local IP address of the phone that is not running kmd.
  • or kmd is not started properly (goal kmd start)

The error indeed indicate that the connection is refused, which usually means kmd is not running at
If you are using sandbox, the port should be 4002.
Note that you can easily check whether kmd works on the above by using in command line:


It should return a lot of lines of JSON.
If it does not the port or the address is not ok. Or kmd is not started.

PS: I would kindly ask you not to post again the same message. If you have a specific question after following any of the steps above (verifying address, port, kmd started, and running curl ...), please answer to this thread with the following information:

  • where is kmd running?
  • how did you install the Algorand software (sandbox, Debian package, …)?
  • where is the flutter app running?
  • what is the output of the above curl command?
  • how did you find the port 44824?

How can I implement this logic in the wallet itself, to be able to offer a multi wallet functionality and therefore derive multiple addresses from the same mnemonic without going through kmd?

One solution is to use BIP39.
You can see one implementation for Algorand there:

Disclaimer: I have nor reviewed this implementation. Algorand makes no representations regarding the functioning or security of wallets, exchanges, or tools mentioned in the answer above, and disclaims any liability therefor.

Right now my node is installed via sandbox and with the curl command I get a response like:

  "consumes": [
    "application / json"
  "produces": [
    "application / json"
  "schemes": [
  "swagger": "2.0",
  "Information": {
    "description": "API for KMD (key management daemon)",
    "title": "for the KMD HTTP API",
    "contact": {
      "e-mail": ""
    "version": "0.0.1"
  "host": "localhost",
  "basePath": "/",
  "paths": {
    "/swagger.json": {
      "get": {
        "description": "Returns the whole swagger specification in json.",
        "produces": [
          "application / json"
        "schemes": [
        "summary": "Get the current swagger specification.",
        "operationId": "SwaggerHandler",
        "answers": {
          "200": {
            "description": "The current specifications of the swagger",
            "pattern": {
              "type": "string"

to continue with all the methods of kmd…

my program is running on flutter and then on chrome at and port 4001 but anyway I get an XMLHttpRequest error and I can’t continue, do you know how else to help me? thanks a lot

What do you mean by “running on flutter and then on chrome at and port 4001”?
Port 4001 is for algod not kmd.

Can you also show the XMLHttpRequest error (copy-paste the exact error and also provide a screenshot as this can be helpful - screenshot including the address bar and the developer console with the error on the side).