Nest js APP problem
HI all. I just deployed an docker image of NestJS app.
Looking into logs everythings looks fine, but for some reason the app is not available on public. I set in the main.ts
const port = process.env.APP_PORT || 3000;
loggerService.log(
Listening on port ${port}
);
await app.listen(port, '0.0.0.0');
and in logs i can see
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [MetricsService] Listening on port 80
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RoutesResolver] AppController {/api} (version: 1): +10ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RouterExplorer] Mapped {/api, GET} (version: 1) route +3ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RoutesResolver] AuthController {/api/auth} (version: 1): +0ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RouterExplorer] Mapped {/api/auth/log-in, POST} (version: 1) route +1ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RouterExplorer] Mapped {/api/auth/log-out, POST} (version: 1) route +1ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RouterExplorer] Mapped {/api/auth/is-logged-in, GET} (version: 1) route +0ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RoutesResolver] MetricsController {/api/metrics} (version: 1): +0ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [RouterExplorer] Mapped {/api/metrics, POST} (version: 1) route +1ms
[Nest] 7 - 02/22/2024, 9:58:29 AM LOG [NestApplication] Nest application successfully started +3ms
i added a healtcheck on endpoint
/api/v1
on local works fine but in build logs i see
Attempt #14 failed with service unavailable. Continuing to retry for 27s
1/1 replicas never became healthy!
Healthcheck failed!
any potential solution?4 Replies
Project ID:
5153932d-a5b8-41c5-b810-2e152a831145
5153932d-a5b8-41c5-b810-2e152a831145/service/a2f7c444-934b-4128-af7c-47c498891855
Solution
here:
you're listening to the
APP_PORT
variable, Railway specifies which port to use in the PORT
variable though, mind changing that line to:
^ explanation: https://docs.railway.app/guides/fixing-common-errors