Skip to content

Node Express App not reachable at 0.0.0.0 #4732

Description

@rupamkairi

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions