Share via

Issue Deploying Next.js App to Azure App Service – Container Exited, Failing Site Start

Tejaswini 0 Reputation points
24 Mar 2025, 07:51

I am trying to deploy a Next.js application to Azure App Service, but I keep encountering the following error in the log stream:

ERROR - Container b2c_0_961f87fc for site b2c has exited, failing site start

ERROR - Container b2c_0_961f87fc didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

Additionally, when trying to access the application, I see this message:

:( Application Error

If you are the application administrator, you can access the diagnostic resources.

I have already tried the following troubleshooting steps:

Set the PORT environment variable in my Next.js app (process.env.PORT || 8080).

Changed the port to 3000, but the issue persists.

Verified that WEBSITES_PORT is set correctly in the Azure App Service configuration.

Checked the logs, but there are no additional details explaining why the container is exiting.

Could anyone help me identify what might be causing this issue and how to resolve it? Any guidance on debugging this further would be greatly appreciated.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,549 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alekhya Vaddepally 240 Reputation points Microsoft External Staff
    24 Mar 2025, 10:58

    Hi Tejaswini,

    Your Azure App Service has an issue with the deployed Next.js app. Specifically, the application’s container is exiting and is unable to respond to HTTP pings.

    Ensure your container’s configuration file is set to listen on the correct port. You stated that the PORT environment variable was set, which is great, but also confirm that your Next.js application is configured to listen to that port as well.

    If the App Service Plan is under allocated in resources like CPU and memory, the container will not run as expected. Insufficient resources can lead to unexpected container exits.

    A few reasons your application can exit unexpectedly is if there are unhandled exceptions or errors in the code. To troubleshoot, try running the app locally to see if there are any issues that may not be obvious in the Azure logs.

    For custom Docker containers, ensure that the configurations for DOCKER_CUSTOM_IMAGE_NAME and STARTUP_COMMAND are set.

    If you have access, attempt to run the container locally with Docker first. Testing the container outside of Azure can determine if the issue is related to the Azure environment or the application.
    https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid#enable-logging-for-nextjs
    https://learn.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-9.0
    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-iis-errors-reference?view=aspnetcore-9.0
    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    Let me know if you have any further Queries.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.