Trouble deploying to DO’s app platform

default discord avatar
samtietjenlast year
1 1

The error that I'm getting is during the deployment phase and reads "Deploy Error: Health Checks".

Some details:

  • I'm attempting to launch the NextJS Custom Server Boilerplate https://github.com/payloadcms/nextjs-custom-server
  • I'm letting DO use their default node Buildpack, no Dockerfile.
  • I bought a fresh MongoDB cluster which seems to connect fine.
  • I have no issues in my local dev environment.
  • The build succeeds and I only get the error at the end of deployment after yarn serve says it's connected to the DB (and essentially finished)

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 🙏

  • Selected Answer
    discord user avatar
    denolfe
    last year

    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/

    3 replies
  • discord user avatar
    DanRibbens
    last year

    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}...`);
    });
  • default discord avatar
    samtietjenlast year

    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!
    
  • default discord avatar
    samtietjenlast year

    Nevermind! Forgot I had to change the health check route under settings. Works now. Thanks guys!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.