Error: v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v2

This is my first time deploying on Fly.io, I run the deploy command the first time and everything was successful but my app is not working, so I made some change in my file by adding postgres cluster I got when I launch my app with Fly. So when I tried to deploy the second time, my deployment process was aborted when its almost done. I went through the troubleshoot page on fly.io and make changes to my files. But I still get the error. Pls help me out. Here is my dockerfile

FROM node:16.17.0-alpine3.15

EXPOSE 80
EXPOSE 443
EXPOSE 8080

WORKDIR /usr/app

COPY package.json .

RUN yarn

COPY . .

CMD yarn dev

Here is my fly.toml file which was generated automatically.

# fly.toml file generated for naira-bck on 2022-09-19T15:03:16+01:00

app = "naira-bck"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Here is my main file: server.js


import express from "express"
import rootRoute from "./src/root_Route.js"
import cookieParser from "cookie-parser"
import passport from "passport"
import connectPgSimple from "connect-pg-simple"
import session from "express-session"
import dotenv from "dotenv"
import cors from "cors"
import "./src/LIB/DB-Client.js"
import "./src/PASSPORT_STRATEGY/google-auth-strategy.js"
import "./src/PASSPORT_STRATEGY/facebook-auth-strategy.js"
import { scheduleJob } from "node-schedule"
import pool from "./src/LIB/DB-Client.js"
dotenv.config()
const app = express()

app.use(
  cors({
    origin: ["http://localhost:3000", "https://nairaonly-frontend.netlify.app"],
    credentials: true,
    methods: "GET, PUT, POST, DELETE",
    optionsSuccessStatus: 200
  })
)
const PgStore = connectPgSimple(session)
const store = new PgStore({ schemaName: "hidden", createTableIfMissing: true })

app.use(express.json())
app.use(cookieParser())
app.set("trust proxy", 1)

app.use(
  session({
    store: store,
    secret: "myscecret",
    saveUninitialized: false,
    resave: false,
    cookie: {
      maxAge: 1000 * 60 * 60 * 24,
      secure: true,
      httpOnly: true,
      sameSite: "none",
    },
  })
)

app.get("/", (req, res) => {
  const userId = req.session.user ?? req.user
  res.send("API Running...")
})

app.use(passport.initialize())
app.use(passport.session())
rootRoute(app)

const PORT = process.env.PORT || 4000

app.listen(PORT, (req, res) => console.log(`Server running on PORT:${PORT}...`))

Instead of:

Can you try:

app.listen(PORT, "0.0.0.0", (req, res) => console.log(`Server running on PORT:${PORT}...`))

It works now thanks

I got it solve now, thanks