Connection refused between 2 Docker Containers running on AWS EC2 Ubuntu instance

I’ve cloned my project from GitHub to my AWS Ubuntu EC2 instance and I’m attempting to Deploy/Host it using Docker containers. The frontend of my application is an Angular project that I have built out to the dist folder and I intend to use Nginx to be able to view it.

The Backend of my application is a Node server thats running with Express. The problem I’m having seems to be with my Docker configuration.

When I run docker-compose up –build -d, I visit my ec2 IP address and the application is there and I can interact with it but when I try loading a resource from the Node Backend I get a connection refused with a Http Error Response in the Browser as shown below.

enter image description here

The following is my docker config files:


version: '3'
    build: ./Crypto-Trader
      - "80:80"
      - node
      - local

    build: ./Server/Node
      - "3000:3000"
      - local

    driver: bridge

Dockerfile for Frontend config

FROM nginx

COPY ./dist/Crypto-Trader /usr/share/nginx/html


Dockerfile for Node Backend

FROM node


COPY . /src

RUN npm install


CMD ["npm", "start"]

I should also mention in my Angular project I have an environment variable for the url connection string set up like so

export const environment = {
  production: true,
  dockerIP: 'node'

So in my Angular services the connection string to the backend would look something like:


I’ve tried a couple of different ways to connect to the backend by changing the dockerIP to: or localhost and neither have worked so I’m at a loss of what to do now.

In my ec2 instance I’ve ran the Node container separately and been able to access data by running this curl command on the command line:

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET

but whenever I run the two containers together there seems to be a communication error between them.

So I hope I’ve provided enough information for someone to help me out I’m not sure what else I can try for the 2 containers to communicate. Thanks in advance to anyone who replies with an answer.

Source: New feed
Source Url Connection refused between 2 Docker Containers running on AWS EC2 Ubuntu instance