Deploying a NestJS app - deployment stuck at "In progress"

Hello,

I’m new to Render.com and I’m having a really hard time trying to get my NestJS app to run. I’m not doing anything crazy, here’s my main.ts file:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
	const port = process.env.PORT || 3333;

	await app.listen(port, () => {
    console.log(`Listening on port ${port}`);
  });
}
bootstrap();

My Build command:

npm install && npm run build

My Start command:

npm run start:prod

Everything works great locally, and everything looks fine in the deployment logs on Render:

Jun 21 08:54:09 PM  > nest build
Jun 21 08:54:34 PM  ==> Uploading build...
Jun 21 08:55:02 PM  ==> Build successful 🎉
Jun 21 08:55:02 PM  ==> Deploying...
Jun 21 08:56:02 PM  ==> Detected Node version 14.16.1
Jun 21 08:56:02 PM  ==> Starting service with 'npm run start:prod'
Jun 21 08:56:03 PM  
Jun 21 08:56:03 PM  > tc-backend-nest@0.0.1 start:prod /opt/render/project/src
Jun 21 08:56:03 PM  > NODE_ENV=production node dist/src/main
Jun 21 08:56:03 PM  
Jun 21 08:56:07 PM  [Nest] 59   - 06/22/2021, 2:56:07 AM   [NestFactory] Starting Nest application...
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] MuxModule dependencies initialized +508ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] SentryModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] RedisModule dependencies initialized +0ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] LoggerModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] PassportModule dependencies initialized +0ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] ConfigHostModule dependencies initialized +3ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] UsersModule dependencies initialized +0ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] DiscoveryModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] LoggerCoreModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] ConfigModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] ConfigModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] EventEmitterModule dependencies initialized +2ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] JwtModule dependencies initialized +15ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] SentryCoreModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] MuxCoreModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] RedisCoreModule dependencies initialized +0ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] VideosModule dependencies initialized +1ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] AppModule dependencies initialized +4ms
Jun 21 08:56:08 PM  [Nest] 59   - 06/22/2021, 2:56:08 AM   [InstanceLoader] AuthModule dependencies initialized +2ms
Jun 21 08:56:09 PM  Listening on port 10000

But the deployment is just stuck on “In Progress”. The app is built and should be running successfully, but it’s getting hung up on something. Am I doing something wrong here?

Any sort of guidance is much appreciated!

I finally figured it out. I’m using the Fastify adapter instead of Express, and here’s what I found straight from the docs:

By default, Fastify listens only on the localhost 127.0.0.1 interface (read more). If you want to accept connections on other hosts, you should specify '0.0.0.0' in the listen() call:

So I changed:

await app.listen(port)

to

await app.listen(port, '0.0.0.0');

and it works great now. I hope this helps someone else down the road!

1 Like