Diego Bisego
Diego Bisego

Reputation: 1

ERROR - Container xxx didn't respond to HTTP pings on port: xxx, failing site start

I am testing the Azure Service App service to deploy an application in Nodejs (nextjs on the front and nestjs on the back). I created the instance in Linux, and linked my code to GitHub to use it with GitHub actions. The problem I have is that, in my code, I do not set it to use any specific port, I let Azure assign it to me, but it gives me the following error:

ERROR - Container xxx didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging. Error 2024-03-20T20:52:48.487 ERROR - Container xxx for site costosapp-prueba has exited, failing site start

In my case I am not using Dockerfile in my code, but apparently Linux internally creates a container to host the app. I tried manually assigning a port to my app from my code, I even used Dockerfile to try exposing the port, but everything always leads to the same result.

Do you know what I'm doing wrong? There is nothing complicated about registering the instance. I have even followed tutorials and do exactly the same steps and get to the same problem. Help me please? :)

I have already tried to assign a port to the code, I have tried to use Dockerfile, I even added environment variables to the app but I still have the same result.

Upvotes: 0

Views: 14013

Answers (1)

Aslesha Kantamsetti
Aslesha Kantamsetti

Reputation: 1501

I created a web app with Next.js for the frontend and Nest.js for the backend, and successfully deployed it to Azure App Service. I created two Azure web apps in the Azure portal to deploy the frontend and backend.

This is my main.ts file. If you hardcode the port, change it like this:

await app.listen(process.env.PORT || 3000);

Also, enable CORS as shown below.

main.ts:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableCors({
    origin: 'http://localhost:3001', 
    methods: 'GET',   
    allowedHeaders: 'Content-Type, Accept', 
  });
  await app.listen(process.env.PORT || 3000);
}
bootstrap();

After deployment, I also faced the same issue with NestJS, as shown below.

enter image description here

For the "Container didn't respond to HTTP pings" error, add any of these Startup Commands

  pm2 start dist/main.js --no-daemon
  npm run start:prod
  node dist/main

as shown below.

enter image description here

Azure Nestjs Output:

enter image description here

Azure Nextjs Output:

enter image description here

Upvotes: 0

Related Questions