- Newest
- Most votes
- Most comments
Based on your description, there are several potential reasons why your App Runner deployment is failing at the health check stage:
- Port Mismatch: This is likely the primary issue. Your container is configured to listen on port 3000, but App Runner might be expecting traffic on port 8080 by default. You have two options:
- Configure App Runner to use port 3000 in your service settings
- Modify your container to listen on port 8080 instead
-
Health Check Path: Ensure that your Next.js application actually has a
/api/healthzendpoint that returns a 200 OK response. If this endpoint doesn't exist or returns a non-200 status code, the health check will fail. You might need to create this endpoint in your Next.js app. -
Application Startup Time: If your Next.js application takes longer to initialize than the health check timeout allows, the check might fail. Consider adjusting the health check timeout and interval settings in your App Runner configuration.
-
Environment Variables: Verify that all necessary environment variables are properly set in your App Runner configuration, especially if your application requires specific variables to function correctly.
-
Network Configuration: Make sure your application is binding to
0.0.0.0(which you've set withHOSTNAME="0.0.0.0") to accept connections from outside the container.
For Next.js specifically with App Runner:
- The standalone output from Next.js should work fine with your current approach of running
node server.js - Make sure your Next.js app is properly handling the health check path
- Consider adding a simple health check endpoint in your Next.js app if you haven't already
Regarding your concern about quotas or account restrictions - while this is possible, it's less likely to be the issue since you're seeing specific health check failures rather than provisioning failures. The logs indicate that App Runner is able to pull your image and attempt to deploy it, suggesting that quota issues aren't the primary problem.
I recommend first addressing the port configuration issue by either:
- Updating your App Runner configuration to specify port 3000, or
- Modifying your Dockerfile to use port 8080 (change both the ENV PORT and EXPOSE directives)
Sources
Why has Aws Runner failed to deploy the image even though it is working fine my local machine and everything configured properly | AWS re:Post
Why is registered target health check failing | AWS re:Post
Failure management - Container Build Lens
answered a year ago
Relevant content
asked 3 years ago
