coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
31.48k stars 1.61k forks source link

[Bug]: Always failed on health check 10/10 #3101

Closed ardiansyaherwin closed 2 days ago

ardiansyaherwin commented 4 weeks ago

Description

Hi, My project is using PayloadCMS, it's a NextJS CMS framework. The build is succeed. the error happens on the 10th health check. While in the middle of healthchecking, I frequently check the app frontpage it works well, but then when the healtchecking 10th fails, the app also broken.

Not sure how to explain it more, here's the log:

[2024-Aug-16 01:00:22.119947] Attempt 10 of 10 | Healthcheck status: "unhealthy"
[2024-Aug-16 01:00:22.123775] Healthcheck logs: (no logs) | Return code: 1
[2024-Aug-16 01:00:22.125893] ----------------------------------------
[2024-Aug-16 01:00:22.128220] Container logs:
[2024-Aug-16 01:00:22.228035] > my-app@1.0.0 start /app
> cross-env NODE_OPTIONS=--no-deprecation next start

▲ Next.js 15.0.0-canary.104
- Local: http://localhost:3000/

✓ Starting...
✓ Ready in 491ms
[2024-Aug-16 01:00:22.233098] ----------------------------------------
[2024-Aug-16 01:00:22.236228] Removing old containers.
[2024-Aug-16 01:00:22.238872] New container is not healthy, rolling back to the old container.

and here's my health checks config:

Screenshot 2024-08-16 at 08 04 34

Minimal Reproduction (if possible, example repository)

Exception or Error

No response

Version

v4.0.0-beta.323

Cloud?

andrasbacsai commented 4 weeks ago

Can you try out with http and not https? Also make sure that / returns a http 200.

CelestialLemon commented 4 weeks ago

I'm also facing a similar issue. I am not able to view my app on the generated domain. The build is successful and if I navigate to the app using VPS ip address and port number I can see its running. If I do curl http://localhost:3000 using a ssh session its giving proper response. But the health check keeps failing for the application. Its the same even if health checks are disabled.

Unlike OP I'm not able to view my app for some time before the health check fails. Its just 502 Bad gateway all the time. Not sure if both issues are similar or different. I'm new to coolify and self hosting and I followed online tutorials for setting it up, maybe I'm doing something wrong.

I'll post some config screenshots below.

image image image

djsisson commented 4 weeks ago

@CelestialLemon you're mapping port 3000 on host to port 80 in container?? can you try removing the port mappings just leave it as port 3000 exposed assuming your app is running on port 3000

CelestialLemon commented 3 weeks ago

No I'm using nginx to serve the app which by default runs on 80. Anyways I still tried what you suggested and it did not work. It also made the app not accessible via ip-address+port @djsisson

djsisson commented 3 weeks ago

if youre running on port 80 then just put expose 80 and leave port mapping blank,

oh i misread so you arent using a domain to access but only through ip? if so ignore what i said, but you would need to change expose to 80 in either case since your app is running on 80 thats what you need to expose

to clarify, the ports exposed is telling other containers what port to use for this container, port mappings is telling the outside world what port on the host ip to use to access the service inside this container

I'm also facing a similar issue. I am not able to view my app on the generated domain

this is because you are telling the domain to access port 3000 in exposes not port 80

CelestialLemon commented 3 weeks ago

This works. Thanks a lot @djsisson. So to do here what I wanted to do I can set port exposes as 80 and port mapping as 3000:80. Tried it and it works. Thanks again.