I have a javascript file (client.js) that runs node-fetch to make GET requests to my server. My server is listening on port 3000. Whenever I create a Docker container to run the client file, I get the following error:
(node:9) UnhandledPromiseRejectionWarning: FetchError: request to http://localhost:3000/selectItem/ failed, reason: connect ECONNREFUSED 127.0.0.1:3000
When I run the client file without any container, it works fine. I just want to have multiple container instances that run the client.js file.
I tried solutions like Node.js Error: connect ECONNREFUSED, but they didn't work.
My Dockerfile:
FROM node:10
WORKDIR /client
COPY package*.json ./
RUN npm install
COPY . .
CMD node client
EXPOSE 3000
Thank you :)