# K8s service cannot work with JSON API

**URL:** <https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263>\
**Category:** App Development\
**Tags:** json-api\
**Created:** [March 14, 2023, 12:05pm UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263 "2023-03-14T12:05:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![532213748](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/532213748/32/6075_2.png) [@532213748](https://forum.canton.network/u/532213748)\
**Post date:** [March 14, 2023, 12:05pm UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/1 "2023-03-14T12:05:40Z")

</div>

I started a JSON API service inside the pod and port-forward out is available but via service access reported 503 error. What do I need to configure?

---

<div class="post-metadata">

**Author:** ![Mate\_Varga](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mate_varga/32/2308_2.png) [@Mate\_Varga](https://forum.canton.network/u/Mate_Varga)\
**Post date:** [March 14, 2023, 2:04pm UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/2 "2023-03-14T14:04:06Z")

</div>

Hi @532213748,

I suspect you kept the the listening address as the default, which is localhost. Add the `--address 0.0.0.0` option to make the process bind to the other interfaces as well.

Kind Regards,  
Mate

---

<div class="post-metadata">

**Author:** ![532213748](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/532213748/32/6075_2.png) [@532213748](https://forum.canton.network/u/532213748)\
**Post date:** [March 15, 2023, 5:33am UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/3 "2023-03-15T05:33:58Z")

</div>

Hi @Mate_Varga Both Participant Node and JSON API configuration have ‘‘address=0.0.0.0’’, it also cannot work well.

---

<div class="post-metadata">

**Author:** ![Mate\_Varga](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mate_varga/32/2308_2.png) [@Mate\_Varga](https://forum.canton.network/u/Mate_Varga)\
**Post date:** [March 15, 2023, 4:53pm UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/4 "2023-03-15T16:53:24Z")

</div>

Can you share your configuration files for both the participant node, the json api server and the kubernetes objects representing them and their network related config? If it is sensitive feel free to send them is a private message.

---

<div class="post-metadata">

**Author:** ![532213748](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/532213748/32/6075_2.png) [@532213748](https://forum.canton.network/u/532213748)\
**Post date:** [March 16, 2023, 5:39am UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/5 "2023-03-16T05:39:43Z")

</div>

I am just testing now, you can see they are in two configmaps:  
apiVersion: v1  
data:  
participant\_config: |  
canton {  
participants {  
participant {  
storage.type = memory  
admin-api.port = 5012  
ledger-api.port = 5011  
ledger-api.address = 0.0.0.0  
}  
}  
// enable ledger\_api commands for our getting started guide  
features.enable-testing-commands = yes  
features.enable-preview-commands = yes  
}  
kind: ConfigMap

apiVersion: v1  
data:  
json\_api\_config: |  
{  
server {  
address = 0.0.0.0  
port = 8080  
}  
ledger-api {  
address = “localhost”  
port = 5011  
}  
}  
kind: ConfigMap

---

<div class="post-metadata">

**Author:** ![Mate\_Varga](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mate_varga/32/2308_2.png) [@Mate\_Varga](https://forum.canton.network/u/Mate_Varga)\
**Post date:** [March 16, 2023, 6:04am UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/6 "2023-03-16T06:04:23Z")

</div>

So how is your network setup, are you running the containers in the same pod?  
What is the exact error message you are receiving?

---

<div class="post-metadata">

**Author:** ![532213748](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/532213748/32/6075_2.png) [@532213748](https://forum.canton.network/u/532213748)\
**Post date:** [March 16, 2023, 7:56am UTC](https://forum.canton.network/t/k8s-service-cannot-work-with-json-api/6263/7 "2023-03-16T07:56:02Z")

</div>

I built my Daml network as following:  
Step 1. Create Domain, I created a pod and a service. Domain configuration：

```haskell
canton {
  domains {
    mydomain {
          storage.type = memory
          public-api.port = 10018
          public-api.address = 0.0.0.0
          admin-api.port = 10019
    }
  }
}

```

Step 2. Create Participant Node. In this step I create a pod and a service, there are two containers in the pod, one of which used for JSON API.  
Participant Node configuration:

```haskell
canton {
      participants {
        participant {
          storage.type = memory
          admin-api.port = 5012
          ledger-api.port = 5011
          ledger-api.address = 0.0.0.0
        }
      }
      // enable ledger_api commands for our getting started guide
      features.enable-testing-commands = yes
      features.enable-preview-commands = yes
    }

```

JSON API configuration:

```haskell
 {
      server {
        address = 0.0.0.0
        port = 8080
      }
      ledger-api {
        address = "localhost"
        port = 5011
      }
    }

```

Step 3. Connect to Domain use following code:

```haskell
    nodes.local.start()
    val domainUrl = sys.env.get("DOMAIN_URL").getOrElse("http://canton-domain-service:10018")
    val myself = participant
    myself.domains.connect("mydomain", domainUrl)
    myself.health.ping(myself)

```

Step 4. After that I call json api in one of the pods with curl command:

```haskell
curl -H "Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhbGljZSIsInNjb3BlIjoiZGFtbF9sZWRnZXJfYXBpIn0.fQi6KFWxgcQQ9eB2oX-dM9wv5u0D3BvUUsFdydtz3Bk" daml-json-api-778f887b6f-dvvvn:8080/v1/user

```

“daml-json-api-778f887b6f-dvvvn” is service name.  
and return an error:

```haskell
{"errors":["UNAVAILABLE: io exception"],"ledgerApiError":{"code":14,"details":[],"message":"io exception"},"status":503}

```
