The error that I'm getting is during the deployment phase and reads "Deploy Error: Health Checks".
Some details:
I'm assuming it's how I have my env vars set. Specifically NEXT_PUBLIC_SERVER_URL and PAYLOAD_PUBLIC_SERVER_URL, which I've tried every imaginable combination of things. I've tried writing a Dockerfile for it, but haven't had much luck with that either.
I'm sure I'm doing something very dumb here.
Any help would be extremely appreciated 🙏
Typically, any platform's health check would be pinging the application to see if it received a good HTTP response. If it is a good response, it would be considered healthy.
It sounds like DO's health checks are failing, so it is likely trying to restart your application. I'd check out their health check documentation here to see how it's configured. It looks like it checks on port 8080 as default - it should match your application port.
These links look relevant:
https://docs.digitalocean.com/glossary/health-check/
https://docs.digitalocean.com/support/my-app-deployment-failed-because-of-a-health-check/
You can customize the http health check endpoint in DO. It is common to a route to your express app for your check. Here is an eample of a server that adds a check on GET /health
:
// server.ts
import express from 'express';
import payload from 'payload';
import dotenv from 'dotenv';
dotenv.config();
const server = express();
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGO_URL,
express: server,
});
// health check
server.get('/health', (req, res) => {
res.send('ok');
});
server.listen(process.env.PORT, async () => {
console.log(`Server listening on ${process.env.PORT}...`);
});
Yep saw those links! Pretty sure I have everything I should set to 8080. Added the /health route, no luck there either. Any ideas? These are the last couple of lines from the console before the health check error:
[payload] [2022-12-06 14:26:44] yarn run v1.22.19
[payload] [2022-12-06 14:26:44] $ cross-env NODE_ENV=production node dist/index.js
[payload] [2022-12-06 14:26:49] [14:26:49] INFO (payload): Starting Payload...
[payload] [2022-12-06 14:26:54] NextJS started
[payload] [2022-12-06 14:26:54] Server listening on 8080...
[payload] [2022-12-06 14:26:55] [14:26:55] INFO (payload): Connected to Mongo server successfully!
Nevermind! Forgot I had to change the health check route under settings. Works now. Thanks guys!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.