ECONNREFUSED ::: Communication between apps

INFORMATION

Relevant information to this issue:

Both apps are up and running:

ISSUE

In auth-service env variables I created an alias to db-service host internal. I use this to communicate to the db-service from auth-service.

auth-service is a publicly exposed app that receives a requests via http, and then wants to communicate to the private db-service using TCP_DB_HOST via tcp port 4200 as shown above. When trying to do that I get ECONNREFUSED.

auth-service:

db-service:

Things that I’ve checked:

  • db-service Dockerfile exposes port 3000 and 4200 on top of what is exposed in qovery
  • auth-service does receive the request (I can see that in the logs)
  • db-service does not receive the request (cannot see anything in the logs)
  • connect to db-service with qovery shell and run netstat -tln | grep 3000 and netstat -tln | grep 4200, both return that it’s listening on both ports
  • connect to auth-service with qovery shel and ran nc -vz app-z04509040-ist-db 4200 did not return anything. Then ran nc -vz app-z04509040-ist-db 3000 got response that is open
  • In the console settings for auth-service I also exposed the port 4200 as private with protocol TCP. Thinking that I need to ‘open’ the port in auth-service
  • same setup with same env variables and http/tcp ports is working locally

Hello @moisesrodriguez ,

When your auth-service sends a request to the db-service, do you specify the port to use ? e.g “$TCP_DB_HOST:$PORT” with $PORT=4200 if I understand correctly.
The $TCP_DB_HOST variable is only the internal host name, without any port

@Melvin_Zottola , yes I do specify the port.

Did you check locally that it worked, by starting manually your containers with docker ?

Yes it works locally, this a list of all the things I’ve tried:

I figured my issue, when starting my TCP server

app.connectMicroservice({
    transport: Transport.TCP,
    options: {
      host: DBModule.tcp_db_host,
      port: DBModule.tcp_db_port,
    }
});

In my local I had 0.0.0.0 but in qovery env I put localhost. Once I changed it to 0.0.0.0 in qovery it worked.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.