App platform - TCP communication between services

Hello, I’m creating architecture where I have one main REST API and few microservices that are doing “hard work” behind the scenes.

On my local environment everything works perfectly, but when I try to set up same architecture on digitalocean apps I get Error: connect ECONNREFUSED

My app spec looks like this:

- build_command: npm run build
  environment_slug: node-js
    branch: develop
    deploy_on_push: true
    repo: html-pdf/html-pdf-api
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xxs
  name: dev-html-pdf-api
  - path: /
  run_command: npm run start:prod
  source_dir: /
- dockerfile_path: Dockerfile
    branch: develop
    deploy_on_push: true
    repo: html-pdf/html-pdf-microservice
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xxs
  - 3000
  name: dev-html-pdf-microservice
  - path: /microservice
  run_command: npm run start:prod
  source_dir: /

so as you can see I’ve enabled 3000 internal port.

About the code, microservice is set up to listen on localhost:3000, and the main api is connecting to it using options:

options: {
          host: 'dev-html-pdf-microservice',
          port: 3000,

Unfortunately I get Error: connect ECONNREFUSED I’ve tried many other options with different options on api and microservice but same result.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bojan D
DigitalOcean Employee
DigitalOcean Employee badge
June 9, 2022
Accepted Answer

Hello, thanks for trying DigitalOcean App Platform. Services running on app platform must bind to and expose the HTTP port on the network interface rather than localhost interface. This is true for both the internal dev-html-pdf-microservice service and the external dev-html-pdf-api service. The connection to the internal private service looks correct, so hopefully this is just the service binding issue.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel