#Error deploying NestJS application to Heroku

26 messages · Page 1 of 1 (latest)

late dew
#

Hi,

I am trying to deploy my first NestJS application in Heroku but receiving the following error
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 180 seconds of launch

Application seems to be starting fine after deployment but when i try to access it PORT binding is failing .

PFA for full log details.

fiery mural
#

What does your main.ts look like?

late dew
#

import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'

async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter())
await app.listen(process.env.PORT || 3000)
console.log(Application running at ${await app.getUrl()})
}
bootstrap()

#

here is my main.ts file content

fiery mural
#

And you don't set port in any env variables/files, right?

late dew
#

no. heroku set the dynamic PORT value in the evn variable

fiery mural
#

Right. What does your procfile look like?

late dew
#

web: yarn start:prod

#

web: yarn start:prod

#

thats all i have in my Procfile

fiery mural
#

Interestingly, there's a heroku process that seems to be trying to start alongside the app process

late dew
#

is there a way to stop the other process

#

do we have any buildpack for NestJS in heroku

fiery mural
#

I don't know how it's being started

fiery mural
late dew
#

we have other NodeJS application thats working fine

#

do you think it might be related to Fastify?

fiery mural
#

Ah, possibly. Do await app.listen(process.env.PORT, '0.0.0.0')

late dew
#

let me try this

#

oh wow it works

#

🥳

#

whats the difference

#

just trying to understand

fiery mural
#

It has to do with how fastify, by default, only things to the localhost and you have to open up the machine to actually listen to externally incoming traffic

late dew
#

got it

#

i already spent like half a day with this issue