Node Express App not reachable at 0.0.0.0

Open
#4,732 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
docker, node.js, typescript
Domain
backend, cloud, devops

Research direction

Start by comparing the listen setup in index.ts, the Dockerfile CMD, and the [http_service] internal_port in fly.toml with the deployed startup logs. Check which process is actually running and whether it exposes 0.0.0.0:10000 inside the machine. Done means fly deploy detects the service and the deployment URL is reachable.

Written by the indexing model from the issue text.

Description

bug

The app is not listening on the expected address and will not be reachable by fly-proxy.

I always get this error while running fly deploy.

# .env

PORT = 10000
// index.ts

export const PORT = +process.env.PORT || 10000;
const HOST = "0.0.0.0";

server.listen(PORT, HOST, () => {
  console.log(`[Info] Local access: http://localhost:${PORT}`);
  console.log(`[Info] Network access: http://${HOST}:${PORT}`);
});
// package.json

  "scripts": {
    "postinstall": "npx prisma generate",
    "dev": "npx cross-env NODE_ENV=development tsx watch src/index.ts",
    "start": "node dist/index.cjs",
    "build": "pkgroll",
  },

This gives logs like following during Development & Production:

❯ npm run dev

> server@1.0.0 dev
> npx cross-env NODE_ENV=development tsx watch src/index.ts

[Database] Initializing Prisma Client...
[Startup] Starting server in development mode...
[Startup] Target port: 10000
[Startup] Attempting to listen on 0.0.0.0:10000...
[Info] Local access: http://localhost:10000
[Info] Network access: http://0.0.0.0:10000

or,

❯ npm run start

> server@1.0.0 start
> npx cross-env NODE_ENV=production node dist/index.mjs

[Startup] Starting server in production mode...
[Startup] Target port: 10000
[Success] Server is listening on 0.0.0.0:10000
[Info] Local access: http://localhost:10000

My docker file looks like following -

FROM node:24-slim AS base

LABEL fly_launch_runtime="Node.js"

WORKDIR /app

FROM base AS build

# Install development dependencies as well since we use tsx to run the app
COPY --link package*.json ./

# Copy all Config files
COPY --link .env ./
COPY --link prisma.config.ts ./
COPY --link src/prisma ./src/prisma

RUN npm install

# Copy the rest of the application
COPY --link . .
RUN npm run build

FROM base
COPY --from=build /app /app

# Ensure PORT is set if not provided by environment
ENV PORT=10000
EXPOSE 10000

CMD ["npm", "run", "dev"]

Following is my fly.toml file:

app = 'ebc-server'
primary_region = 'sin'


[build]

[http_service]
  internal_port = 10000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ["app"]

[[vm]]
  memory = "256mb"
  cpus = 1

But at the fly deploy I always get the warning error:

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.2] Machine 7817215c94d0d8 reached started state
You can fix this by configuring your app to listen on the following addresses:
  - 0.0.0.0:10000
Found these processes inside the machine with open listening sockets:
  PROCESS        | ADDRESSES
-----------------*----------------------------------------
  /.fly/hallpass | [fdaa:39:cf67:a7b:5f8:bfc7:e911:2]:22

& Deployment https://ebc-server.fly.dev/ is not reachable.

The Dashboard "Logs & Errors" shows this error:

08:33:40
> npx cross-env NODE_ENV=development tsx watch src/index.ts
08:35:28
[PC01] instance refused connection. is your app listening on 0.0.0.0:10000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
08:35:28
[PR03] could not find a good candidate within 2 attempts at load balancing. last error: [PC01] instance refused connection. is your app listening on 0.0.0.0:10000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
08:35:40
[PC01] instance refused connection. is your app listening on 0.0.0.0:10000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)

I am using fly shared IPs.

❯ fly ips list
VERSION IP                      TYPE                            REGION  CREATED AT
v6      2a09:8280:1::ce:f9e0:0  public ingress (dedicated)      global  49m12s ago
v4      66.241.124.68           public ingress (shared)                 Jan 1 0001 00:00

Dominant language
Go
Stars
1.7k
Forks
311
Avg merge
12h 50m
Merged PRs (30d)
78

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from superfly/flyctl

All issues in superfly/flyctl

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.