0

I have a node JS express app running on Linux container. The node JS app inside the Linux container is making API calls to a URL hosted in the host machine (A URL hosted in Windows IIS).

But I'm getting the following error while making API call from the container:

Error: connect ECONNREFUSED 127.0.0.1:443

I have configured the NodeJS app with Service_BaseURL configured in my windows host file. I think the container is not able to resolve the Service_BaseURL. Below is my dockerfile:

FROM node:10

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

ENV HOSTNAME localhost
ENV PORT 8080
ENV LOGGING_PATH /var/lib/docker/containers/logs
ENV Service_BaseURL https://local-service.org

EXPOSE 8080
CMD [ "node", "server.js" ]

Any help greatly appreciated.

  • 1
    Does this answer your question? [How to get the IP address of the docker host from inside a docker container](https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container). TLDR;, it's host.docker.internal – Robert Moskal Dec 03 '19 at 16:00
  • I think it suggests to use host.docker.internal as host's IP. So in my case, How should I map my URL with host.docker.internal? I'm just the beginner of Docker. So please let me know your suggestions. Thanks, much! – Mushthaque Ismail Dec 04 '19 at 00:41
  • Your Service_BaseURL should point at http://host.docker.internal. I don't think you are going to get https to work. – Robert Moskal Dec 04 '19 at 01:07
  • I have updated Dockerfile like following: ENV RulesService_BaseURL host.docker.internal But now I'm getting an error like this: connect ECONNREFUSED 127.0.0.1:80 I have multiple sites configured in my host entry so I think it cannot communicate with right site. So is there any alternate solution that I should follow? – Mushthaque Ismail Dec 04 '19 at 04:41

0 Answers0