Node app not reachable

Hi, this is my first time attempting to deploy something for the backend; it’s an extremely simple Node file. Fly deploy seemed to go alright, but when I try to visit the URL it simply never loads. The log just keeps giving me:

2023-11-04T22:57:17.518 app[e2865101a62398] sjc [info] [ 0.044161] PCI: Fatal: No config space access function found

2023-11-04T22:57:17.749 app[e2865101a62398] sjc [info] INFO Starting init (commit: 15238e9)...

2023-11-04T22:57:17.770 app[e2865101a62398] sjc [info] INFO Preparing to run: `docker-entrypoint.sh node index.js` as root

2023-11-04T22:57:17.780 app[e2865101a62398] sjc [info] INFO [fly api proxy] listening at /.fly/api

2023-11-04T22:57:17.787 app[e2865101a62398] sjc [info] 2023/11/04 22:57:17 listening on [fdaa:3:5896:a7b:16f:dad3:48e9:2]:22 (DNS: [fdaa::3]:53)

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] node:internal/modules/cjs/loader:1078

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] throw err;

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] ^

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] Error: Cannot find module '/app/index.js'

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] at Module._load (node:internal/modules/cjs/loader:920:27)

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] at node:internal/main/run_main_module:23:47 {

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] code: 'MODULE_NOT_FOUND',

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] requireStack: []

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] }

2023-11-04T22:57:17.934 app[e2865101a62398] sjc [info] Node.js v18.14.2

2023-11-04T22:57:18.780 app[e2865101a62398] sjc [info] INFO Main child exited normally with code: 1

2023-11-04T22:57:18.780 app[e2865101a62398] sjc [info] INFO Starting clean up.

2023-11-04T22:57:18.782 app[e2865101a62398] sjc [info] WARN hallpass exited, pid: 306, status: signal: 15 (SIGTERM)

2023-11-04T22:57:18.787 app[e2865101a62398] sjc [info] 2023/11/04 22:57:18 listening on [fdaa:3:5896:a7b:16f:dad3:48e9:2]:22 (DNS: [fdaa::3]:53)

2023-11-04T22:57:19.782 app[e2865101a62398] sjc [info] [ 2.307347] reboot: Restarting system

2023-11-04T22:57:19.923 runner[e2865101a62398] sjc [info] machine has reached its max restart count (10)

I don’t have any app directory or index.js, so I’m not sure where that’s coming from.

When I google some of these messages I see a lot of “make sure your app’s listening to 0.0.0.0 at port 3000”, but I can’t see why that’d be an issue:

app.listen(3000, "0.0.0.0", () => {
  console.log("server listening on port 3000");
});

I thought it could be some sort of region problem so I tried adding a different region, but it gets the same thing. Any thoughts?

Can you post your dockerfile?

It’s trying to run index.js. You said this does not exist so this is likely the issue. I’d rename it to the file of your app wherever app.listen is defined, whether that is app.js or server.js etc.

You can also remove the "0.0.0.0" part on the app.listen call:

app.listen(3000, () => {
  console.log("This should still work!");
});

Well that was easy – you were right, at the bottom of the Dockerfile it had

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "node", "index.js" ]

so I just had to change “index” to “server”, in my case. Sorry about that, I thought I looked through the Dockerfile for any reference to index.js but didn’t see one…

Awesome! Glad to hear it :slight_smile:

Good luck building!

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