Node.js App Not Responding to Requests

Hey Folks,

I’ve been trying to deploy this node.js app on fly.io

and finally got to the point where the logs are saying that the app is running on port 3000

but requesting anything from the server doesn’t work.

Here’s my Dockerfile

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.20.0
FROM node:${NODE_VERSION}-slim AS base

LABEL fly_launch_runtime="Node.js/Prisma"

# Node.js/Prisma app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
ARG PNPM_VERSION=9.5.0
RUN npm install -g pnpm@$PNPM_VERSION


# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential node-gyp openssl pkg-config python-is-python3

# Install node modules
COPY package.json pnpm-lock.yaml ./
RUN pnpm install

# Generate Prisma Client
COPY prisma ./prisma

# Copy application code
COPY . .

# Build application
RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y openssl && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built application
COPY --from=build /app /app

# # Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "pnpm", "run", "start" ]

build command: "build": "pnpm install && npx prisma generate"
start command: "start": "node dist/routers/index.js"

fly.toml

# fly.toml app configuration file generated for uni-shop-backend on 2025-05-14T01:31:03+03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

swap_size_mb = 2048

app = 'uni-shop-backend'
primary_region = 'fra'

[build]

[deploy]
  release_command = 'pnpm run start'

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  size = 'shared-cpu-1x'

I tweaked the dockerfile fly.io generated when running fly launch quite a bit to make it work.

Fly logs just say this:

2025-05-17T14:49:35.613 app[d899942aed5918] fra [info] INFO Sending signal SIGTERM to main child process w/ PID 647

2025-05-17T14:49:35.617 app[d899942aed5918] fra [info]  ELIFECYCLE  Command failed.

2025-05-17T14:49:35.897 app[d899942aed5918] fra [info] INFO Main child exited normally with code: 1

2025-05-17T14:49:35.916 app[d899942aed5918] fra [info] INFO Starting clean up.

2025-05-17T14:49:35.916 app[d899942aed5918] fra [info] WARN could not unmount /rootfs: EINVAL: Invalid argument

2025-05-17T14:49:35.921 app[d899942aed5918] fra [info] [ 602.582553] reboot: Restarting system

2025-05-17T14:49:41.795 runner[0802274b54d618] fra [info] Pulling container image registry.fly.io/uni-shop-backend:deployment-01JVFBGJKZ78G7XRRV936NPQR6

2025-05-17T14:49:42.527 runner[0802274b54d618] fra [info] Successfully prepared image registry.fly.io/uni-shop-backend:deployment-01JVFBGJKZ78G7XRRV936NPQR6 (732.201615ms)

2025-05-17T14:49:45.289 runner[0802274b54d618] fra [info] Configuring firecracker

2025-05-17T14:49:47.469 app[0802274b54d618] fra [info] 2025-05-17T14:49:47.469348471 [01JVFBHSGPJ1CGYND98096SW92:main] Running Firecracker v1.7.0

2025-05-17T14:49:48.173 app[0802274b54d618] fra [info] INFO Starting init (commit: 0f5583484)...

2025-05-17T14:49:48.327 app[0802274b54d618] fra [info] INFO Preparing to run: `docker-entrypoint.sh pnpm run start` as root

2025-05-17T14:49:48.329 app[0802274b54d618] fra [info] INFO [fly api proxy] listening at /.fly/api

2025-05-17T14:49:48.401 runner[0802274b54d618] fra [info] Machine started in 1.176s

2025-05-17T14:49:48.646 app[0802274b54d618] fra [info] 2025/05/17 14:49:48 INFO SSH listening listen_address=[fdaa:14:a800:a7b:3fa:4734:f287:2]:22

2025-05-17T14:49:50.109 app[0802274b54d618] fra [info] > uni-shop-backend@1.0.0 start /app

2025-05-17T14:49:50.109 app[0802274b54d618] fra [info] > node dist/routers/index.js

2025-05-17T14:49:50.459 app[0802274b54d618] fra [info] prisma:warn In production, we recommend using `prisma generate --no-engine` (See: `prisma generate --help`)

2025-05-17T14:49:50.474 app[0802274b54d618] fra [info] Listening on port 3000

I have a few suspicions:

  • The log is saying listening to port 3000 but that’s not logged from my app itself. Not sure if fly.io has some sort of logging for that or my app is being cached from previous deployments from docker. Not sure.
  • The log from running fly deploy from the command line never gets to the point where it has state: destroyed so not sure if that’s a different issue or related.

Are you sure that you wanted this line? It’s identical to the CMD in your Dockerfile, which is very unusual…

(Typically, making those two be the same would cause the ephemeral release Machine to hang, until it’s killed by flyctl, thus preventing any real Machines from ever being created.)

A non-zero exit status from this command will stop the deployment. fly deploy will display logs from the command.

[…]

By default, the release command has 5 minutes to complete before it is killed.

Hope this helps!


Typically it’s the framework (Node, Rails, etc.) that logs this one, rather than your own application code, per se.

1 Like

Okay.

You were right on the money with the release command being unnecessary. I just added it as part of my debugging journey trying to get this to work.

I ended up removing the command running for release. That made no sense and voila, for the first time, the deployment didn’t end up hanging.

Thank you so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.