Not able to run the service locally

Hello, I am trying to run the service on my local by following the steps from the documentation (Run a service locally :: Kalix Documentation) but getting an error after running the docker compose up.

One of the error logs is :

bank-operations-scala-kalix-proxy-1             | {"timestamp":"2022-08-21T14:15:16.761Z","mdc":{"akkaAddress":"akka://kalix-proxy@192.168.128.2:25520","akkaSource":"akka://kalix-proxy/user/discovery-manager","sourceActorSystem":"kalix-proxy"},"logger":"kalix.proxy.DiscoveryManager","message":"Supervisor RestartSupervisor saw failure [2]: Could not connect to user function not available for discovery at [host.docker.internal:8080]","exception":"kalix.proxy.DiscoveryManager$$anon$1: Could not connect to user function not available for discovery at [host.docker.internal:8080]\n","severity":"ERROR","thread":"kalix-proxy-akka.actor.default-dispatcher-10","version":"1.0.10"}

Also, I tried to run the sbt run in another terminal, but the service didn’t run successfully.

The Kalix proxy in the docker container will try to connect to your locally running service at host.docker.internal:8080, the error message you shared says it is not possible to reach any service running at that port, this could be because the service is not started yet (with sbt run for a Scala project) or possibly some problem with docker networking (check that you are on latest docker to start with).

Note that when running locally like this the proxy will try to reconnect with some interval if it didn’t see a service at first, each time it fails it will log an entry like this, even if it eventually suceeds.

I have the latest version of the docker(20.10.14), also after running the docker compose up command I ran the sbt run in a separate terminal and it ran the flow only once like first its bound the service, and then it unbinds it.

12:55:05.082 [kalix-akka.actor.default-dispatcher-2] DEBUG akka.actor.ActorSystemImpl - Binding server using HTTP/2
12:55:05.337 [kalix-akka.actor.default-dispatcher-4] DEBUG akka.io.TcpListener - Successfully bound to /127.0.0.1:8080
12:55:05.351 [kalix-akka.actor.default-dispatcher-4] DEBUG akka.actor.ActorSystemImpl - gRPC server started 127.0.0.1:8080
[success] Total time: 6 s, completed 22-Aug-2022, 12:55:05 PM
12:55:05.527 [kalix-akka.actor.default-dispatcher-4] DEBUG akka.actor.CoordinatedShutdown - Starting coordinated shutdown from JVM shutdown hook
12:55:05.531 [kalix-akka.actor.default-dispatcher-4] INFO akka.actor.CoordinatedShutdown - Running CoordinatedShutdown with reason [JvmExitReason]
12:55:05.532 [kalix-akka.actor.default-dispatcher-4] DEBUG akka.actor.CoordinatedShutdown - Performing phase [before-service-unbind] with [1] tasks.
12:55:05.535 [kalix-akka.actor.default-dispatcher-4] DEBUG akka.actor.CoordinatedShutdown - Performing task [wait-for-proxy-terminated] in CoordinatedShutdown phase [before-service-unbind]
12:55:05.546 [kalix-akka.actor.default-dispatcher-2] DEBUG akka.actor.CoordinatedShutdown - Performing phase [service-unbind] with [1] tasks.
12:55:05.546 [kalix-akka.actor.default-dispatcher-2] DEBUG akka.actor.CoordinatedShutdown - Performing task [http-unbind-/127.0.0.1:8080] in CoordinatedShutdown phase [service-unbind]
12:55:05.549 [kalix-akka.actor.default-dispatcher-2] DEBUG akka.io.TcpListener - Unbinding endpoint /127.0.0.1:8080
12:55:05.551 [kalix-akka.actor.default-dispatcher-3] DEBUG akka.io.TcpListener - Unbound endpoint /127.0.0.1:8080, stopping listener
12:55:05.553 [kalix-akka.actor.default-dispatcher-6] DEBUG akka.actor.CoordinatedShutdown - Performing phase [service-requests-done] with [1] tasks.
12:55:05.554 [kalix-akka.actor.default-dispatcher-6] DEBUG akka.actor.CoordinatedShutdown - Performing task [http-terminate-/127.0.0.1:8080] in CoordinatedShutdown phase [service-requests-done]
12:55:05.557 [kalix-akka.actor.default-dispatcher-2] DEBUG akka.actor.CoordinatedShutdown - Performing phase [service-stop] with [0] tasks
12:55:05.562 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [before-cluster-shutdown] with [0] tasks
12:55:05.562 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [cluster-sharding-shutdown-region] with [0] tasks
12:55:05.562 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [cluster-leave] with [0] tasks
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [cluster-exiting] with [0] tasks
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [cluster-exiting-done] with [0] tasks
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [cluster-shutdown] with [0] tasks
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [before-actor-system-terminate] with [0] tasks
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing phase [actor-system-terminate] with [1] tasks.
12:55:05.563 [kalix-akka.actor.default-dispatcher-7] DEBUG akka.actor.CoordinatedShutdown - Performing task [terminate-system] in CoordinatedShutdown phase [actor-system-terminate]

In the above logs, there are first binding logs, and then it has unbinding logs.

If your Kalix service exits immediately it could be related to a change in sbt 1.6 where it kills the service once main returns. Try setting fork := true in your build.sbt (this should be the default with our samples an g8 template already) .