Question

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:

services:
- build_command: npm run build
  environment_slug: node-js
  gitlab:
    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
  routes:
  - path: /
  run_command: npm run start:prod
  source_dir: /
- dockerfile_path: Dockerfile
  gitlab:
    branch: develop
    deploy_on_push: true
    repo: html-pdf/html-pdf-microservice
  http_port: 8080
  instance_count: 1
  instance_size_slug: basic-xxs
  internal_ports:
  - 3000
  name: dev-html-pdf-microservice
  routes:
  - 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 10.245.138.142:3000. 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 0.0.0.0 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

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.