I’m attempting at deploying a Nodejs/React app onto fly and I’m met with an error message: Database connection failure ConnectionError [SequelizeConnectionError]: Connection terminated unexpectedly
The app-db dashboard logs first said I was reaching a ‘resource limit’ so I upgraded my db from the free tier packages which removed the health check log error but wasn’t the fix that I was looking for. I also checked to see if I missed setting a secret but that wasn’t the fix either.
I was able to connect to the database locally and everything checks out that the database is working and checked that the database is within the same org as my app.
I removed then re-added all secret envs .
After redeploying I’m still met with Health check on port 8080 has failed. Your app is not responding properly. Services exposed on ports [80, 443] will have intermittent failures until the health check passes.
Could this be due to my ports not being configured properly with the toml file? When I start my app locally I run my backend (Nodejs) on port 4000 while my frontend (React) runs on 3000 but after the build my frontend should be running on port 80.
I’m not sure what your healthcheck is but normally with React, that would be run client-side and the Node bit (often an API, if it’s a React SPA) would be server-side.
So if this value is 4000 …
… then this value would also need to be 4000:
That way your node app would be listening on the same port.
If yours is, and you still get an error, that would rule out the port and suggest something else is the issue. I’d e.g check the logs with fly logs to see if there are any other errors reported that would cause a healthcheck to fail. Like a path not existing? I tend to put a simple /healthcheck route in my Node apps for this purpose:
Yeah this error is really odd since the ports are matching up but after adding “::” to app.listen I’m still getting the same health check error and [SequelizeConnectionError]: Connection terminated unexpectedly
ok, so you are not even getting to the point where you are trying to listen. This code tries to connect to the database and only calls listen if that connection succeeded, which it did not.
It looks like you are using postgres. If you are using fly’s postgres, that code could be as simple as new Sequalize(process.env.DATABASE_URL). If you are using a database from elsewhere, you might need to set an ssl option, see Using Heroku Postgres From a Fly App for an example.