Application Sporadically Down With 502

Hello! I have a Nest.js application and just yesterday started experiencing some confusing issues. I am running litefs with the proxy server and just yesterday I scaled the app to the shared-cpu-2x vm and added an additional machine to the primary region. Yesterday I added redis (upstash) and the timing there feels a little suspicious.

A brief description of the issue:

  • Fresh deploys work fine for a period of time
  • After some time, if I refresh the page, the request hangs and eventually receives a 502 (health checks for the application server and the litefs proxy I added this morning still seem to be passing at this point)
  • After some time the application seems to restart and service resumes. It should be noted that during the downtime, I can still access the site via an incognito session or different browser session. I can also access the site via the fly url link from the dashboard.

I am a bit at a loss and would greatly appreciate some help! Happy to provide any additional context as well.



Update - after more carefully reviewing the litefs proxy documentation, I realized that the internal port needed to be mapped to the litefs proxy port. Attached is an updated fly.toml but I am still experiencing this issue.

Are you seeing anything unusual in fly logs? Are you able to run fly ssh console to go into the VM and curl localhost:8080 from there?

Thanks for the response @benbjohnson! I just tried and can successfully curl localhost:8080. Previously I saw an error around redis throwing an error which I wasn’t handling, but after addressing that issue, I am still experiencing the behavior. I consistently see an error that the proxy server had a connection timeout.

Edit - still getting a redis error but yet unsure what is going on or if it’s related. I am just trying to use upstash redis as a session store with an implementation almost exactly to their docs: Express Session with Serverless Redis - Upstash Documentation

In case it helps somebody else, I believe this issue to be resolved. I opted to migrate from the ioredis client to node-redis with a pingInterval configured to keep the redis connection alive. I found these two other threads very helpful:

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