#Connection was forcibly closed by a peer.

12 messages · Page 1 of 1 (latest)

rose tulip
#

HEllo, I having some trouble when running container, in local everything works fine when I curl "http://localhost:3010/" but however it doesn't when curling the container with the same url "http://localhost:3010/". Inside the logs look fine:

[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [NestFactory] Starting Nest application...
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] LoggerModule dependencies initialized +20ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] RepositoryModule dependencies initialized +1ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [InstanceLoader] AuthentificationModule dependencies initialized +1ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RoutesResolver] AppController {/}: +52ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RouterExplorer] Mapped {/, GET} route +2ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RoutesResolver] AuthentificationController {/authentification}: +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RouterExplorer] Mapped {/authentification, POST} route +1ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RouterExplorer] Mapped {/authentification/:authtificationId, GET} route +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RouterExplorer] Mapped {/authentification/:authtificationId, DELETE} route +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [RouterExplorer] Mapped {/authentification/:authtificationId/remove, DELETE} route +0ms
[Nest] 17  - 10/24/2024, 8:55:08 AM     LOG [NestApplication] Nest application successfully started +2ms

When I curl the container, it returns "Connection was forcibly closed by a peer."

worn coyote
rose tulip
worn coyote
#

did you expose and map the port of the container to your host ?

rose tulip
#

Yes from the docker-compose:

ports:
      - "3010:3000"
worn coyote
worn coyote
#

Maybe showing us some code would help. dockerfile and docker-compose

rose tulip
#

This is the part of the docker-compose:

  authentification:
    container_name: auth-service
    restart: "unless-stopped"
    build:
      context: .
      dockerfile: "./backend/microservices/service-authentication/Dockerfile"
      target: development
    ports:
      - "3010:3000"
    env_file:
      - "./backend/microservices/service-authentication/env/.env.development"
    networks:
      - backend_net
      - frontend_net
      - db_net
    depends_on:
      - postgres
#

And this the docker file:

FROM node:18-alpine AS base
WORKDIR /app
COPY ./backend/microservices/service-authentication/ /app/
RUN npm install

FROM base AS development
RUN npm run build

CMD ["npm", "run", "start:prod"]
worn coyote
#

Check if your Nest app is really listening on port 3000.
Then in the dockerfile, try to add EXPOSE 3000.
Then call the http://auth-service:3010

rose tulip