Page loads, but on refresh 502's

Page 502’s then loads, then 502’s and can’t use any of the routes. So confused.

Hey @Mendddd ! Is it your application that’s giving the 502? 502s are server side errors, so your app could be under load, have some misconfiguration in the DNS, or it could be giving invalid responses. Do the logs show any errors you could pursue? To look at logs, use flyctl logs.

Nothing in the logs and I just checked using the generated hostname with {projectname} .fly.dev and it’s working fine, the app is behind cloudflare and using the normal url it’s where it’s 502’ing.

Okay seems to be generating some logs now, I have another app running on fly fine, it’s svelte with node, but this is express with node and not working

2023-09-05T15:34:07Z app[3d8d926dce0148] syd [info]Keep-alive query successful: [ { '1': 1 } ]
2023-09-05T15:34:39Z proxy[3d8d926dce0148] syd [info]Downscaling app dwmb in region syd from 2 machines to 1 machines. Automatically stopping machine 3d8d926dce0148
2023-09-05T15:34:39Z app[3d8d926dce0148] syd [info] INFO Sending signal SIGINT to main child process w/ PID 255
2023-09-05T15:34:39Z app[3d8d926dce0148] syd [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)
2023-09-05T15:34:39Z app[3d8d926dce0148] syd [info] INFO Starting clean up.
2023-09-05T15:34:39Z app[3d8d926dce0148] syd [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-05T15:34:39Z app[3d8d926dce0148] syd [info]2023/09/05 15:34:39 listening on [fdaa:2:e348:a7b:1ae:11a5:9fc5:2]:22 (DNS: [fdaa::3]:53)
2023-09-05T15:34:40Z app[3d8d926dce0148] syd [info][  334.685692] reboot: Restarting system
2023-09-05T15:35:20Z proxy[3d8d9902f92198] syd [info]Downscaling app dwmb in region syd from 1 machines to 0 machines. Automatically stopping machine 3d8d9902f92198
2023-09-05T15:35:20Z app[3d8d9902f92198] syd [info] INFO Sending signal SIGINT to main child process w/ PID 255
2023-09-05T15:35:20Z app[3d8d9902f92198] syd [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)
2023-09-05T15:35:20Z app[3d8d9902f92198] syd [info] INFO Starting clean up.
2023-09-05T15:35:20Z app[3d8d9902f92198] syd [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-05T15:35:20Z app[3d8d9902f92198] syd [info]2023/09/05 15:35:20 listening on [fdaa:2:e348:a7b:f1:2adc:eca2:2]:22 (DNS: [fdaa::3]:53)
2023-09-05T15:35:21Z app[3d8d9902f92198] syd [info][  107.355587] reboot: Restarting system

Those logs look fine, and without seeing your app, it is hard to make recommendations, so instead can you try deploying the following:

mkdir demo
cd demo
npx --yes @flydotio/node-demo@latest

If you can successfully deploy the demo app, the question then becomes what is different between that app and yours? If it helps, the deployment app can be customized to more closely match your application: Vanilla with Candy Sprinkles · The Fly Blog

I can privately send you a gist if that’s more helpful.

Sure. My id at fly.io.

Okay, I’ve sent an email and now building the demo, will see in a sec

demo deploys just fine and I don’t see much difference between mine and the demo other than one uses ejs and one is using tmpl same package.json + deps, same dockerfile basically.

You can configure the demo to run with ejs by passing --ejs as an option. See blog entry for details.

When I comment out your const connection = and connection.connect( lines, I can launch and deploy your app. Relevant information from the logs:

2023-09-05T16:54:17Z app[683d315a115218] iad [info] INFO Preparing to run: `docker-entrypoint.sh node index.js` as root
2023-09-05T16:54:17Z app[683d315a115218] iad [info] INFO [fly api proxy] listening at /.fly/api
2023-09-05T16:54:17Z app[683d315a115218] iad [info]2023/09/05 16:54:17 listening on [fdaa:0:d445:a7b:107:deba:79ea:2]:22 (DNS: [fdaa::3]:53)
2023-09-05T16:54:17Z app[683d315a115218] iad [info]Warning: connect.session() MemoryStore is not
2023-09-05T16:54:17Z app[683d315a115218] iad [info]designed for a production environment, as it will leak
2023-09-05T16:54:17Z app[683d315a115218] iad [info]memory, and will not scale past a single process.
2023-09-05T16:54:17Z app[683d315a115218] iad [info]Server is running at http://localhost:3000

. . .

2023-09-05T16:54:27Z app[32874235c62358] iad [info]Error: Failed to lookup view "login" in views directory "/app/views"
2023-09-05T16:54:27Z app[32874235c62358] iad [info]    at Function.render (/app/node_modules/express/lib/application.js:597:17)

so why would the database be dying here? I have fed the secrets… :\

Any relevant information in the logs? Try fly logs or go to the dashboard for your app and click on monitoring in the left hand sidebar.

I’ll just take a wild guess here. If your database requires ssl, you may need to add the following to your connect call:

    ssl: {
      ca: readFileSync("/etc/ssl/certs/ca-certificates.crt")
    }

And then use this to modify your dockerfile:

npx dockerfile --add=ca-certificates

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