I have docker running. There are no errors in the log file.
But when I try to execute a simple request via Postman
POST -> http://ip:3200/api/login
I get an error:
Error: connect ECONNREFUSED ip:3200
What did I do wrong?
docker ps:
CONTAINER_ID 84b2968aa424
IMAGE top-api:latest
COMMAND "docker-entrypoint.s"
PORTS 0.0.0.0:3200->3200/tcp
NAMES top-api
Dockerfile:
FROM node:12-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN npm add sharp
COPY . .
COPY ./dist ./dist
CMD ["npm", "run", "start:dev"]
docker-compose.yml:
version: '3'
services:
top.api:
image: top-api:latest
container_name: top-api
restart: always
ports:
- 3200:3200
volumes:
- ./.env.dev:/app/.env.dev
CodePudding user response:
From your host you have to connect to: localhost:3200
. So when using postman, target localhost:3200
.
CodePudding user response:
You're probably listening on 127.0.0.1, which is not publicly exposed (see https://pythonspeed.com/articles/docker-connection-refused/ for diagrams).
Try configuring your webserver to listen on 0.0.0.0.
CodePudding user response:
You can try to expose the port 3200 by adding the following line to your Dockerfile:
EXPOSE 3200