Persistent 'Bad Gateway' Errors on Replit Deployment


I keep getting ‘Bad Gateway’ errors on my repl deployments and I am not sure how to fix the issue.
I think the error is probably 7 but I would just like some confirmation that the failure mode is ‘Bad Gateway’.

Troubleshooting tips that do not apply

  1. No - the repl works in the ‘dev’ environment
  2. No - it works continuously in the ‘dev’ environment, so I don’t think it is thisl.
  3. No - there are no errors in the logs.
  4. No - build command passes and works.
  5. No - I do not currently use secrets, I just have a configuration file.
  6. Doubt this - it does not take long to load the initial page. And passes the initial health check?
  7. No - I am using a mongodb atlas database

Troubleshooting that might apply
3. I am not sure how to rule this out. It’s an express app and this is the code I use to run it.

// where process.env.PORT is 8000.
const port = process.env.PORT || 8080
app.listen(port, () => {

I am not sure how consequential port choice is but note that in the logs, it says ‘forwarding local port 8080 to external port 1104’. So I think it just forwards any port I select to the port replit uses.

  1. The specs I use for the deployment are Pro (0.25 vCPU / 1 GiB RAM). I don’t actually know how much RAM the app uses. Most of the time, my repl shows it being under 1 GiB but I have seen it creep over that in the dev environment.

Would this be the kind of think that causes a ‘Bad Gateway’ error?

  1. The .replit configuration file does not contain anything in the deployment section that seems unusual. Though I do not know what the ‘ignorePorts = false’ part means.

That is a secret. So try making a secret for the deployment called PORT and set the value to 8000

Thank you!
I did not think I needed secrets because the repl was private… However, I will now add secrets to the deployment. Does the run command change?

I previously had: ‘npx env-cmd -f ./configuration/production.env node src/index.js’.

Should it now just be: ‘node src/index.js’ ?