NextJS demo failing on deploy from health checks

Hi, trying to give a demo and my deploy is failing on the health checks.

Steps (following Deploy a NextJS Application · Fly Docs):

  1. create generic NextJS app locally, verify runs fine locally
  2. Use fly launch

I’ve left my generated config / dockerfile as is with no modifications.

Results (note that I retried the deploy a few times to see if it was a one-off. this it the latest):

==> Creating release
--> release v3 created

--> You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment

 1 desired, 1 placed, 0 healthy, 1 unhealthy [health checks: 1 total, 1 critical]
Failed Instances

Failure #1

3b4d0e51                3       ewr     run     running 1 total, 1 critical     0               4m49s ago

Recent Events
TIMESTAMP               TYPE            MESSAGE                 
2022-08-09T10:36:54Z    Received        Task received by client
2022-08-09T10:36:55Z    Task Setup      Building Task Directory
2022-08-09T10:37:00Z    Started         Task started by client 

2022-08-09T10:36:57Z   [info]Unpacking image
2022-08-09T10:37:00Z   [info]Preparing kernel init
2022-08-09T10:37:00Z   [info]Configuring firecracker
2022-08-09T10:37:00Z   [info]Starting virtual machine
2022-08-09T10:37:00Z   [info]Starting init (commit: c86b3dc)...
2022-08-09T10:37:00Z   [info]Preparing to run: ` yarn start` as nextjs
2022-08-09T10:37:00Z   [info]2022/08/09 10:37:00 listening on [fdaa:0:7f6a:a7b:ab3:3b4d:e51:2]:22 (DNS: [fdaa::3]:53)
2022-08-09T10:37:01Z   [info]ready - started server on, url: http://localhost:3000
--> v3 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v4 

--> Troubleshooting guide at
Error abort

The only check appears to be the tcp_check? Let me know what I have wrong, thanks!

It looks like your app is configured to listen on 3000? Is this reflected in your fly.toml? It’s possible that health checks aren’t passing if internal_port isn’t set to 3000, too.

That was indeed the issue. Setting the internal_port = 3000 fixed it.

It’s a bit misleading to have the launch script output detected a NextJS app but not template things correctly. Attempted a fix here: Have NextJS template the default NextJS port by grantgustafson · Pull Request #1166 · superfly/flyctl · GitHub