Service keeps crashing and will not restart

The last time my CMS deployed properly was yesterday and there have been no code changes on my code bases for 5 months. Now however my server crashes and when I restart I get the following connection error message; yarn run v1.22.19 $ strapi start [2024-02-05 10:33:14.237] debug: ⛔️ Server wasn't able to start properly. [2024-02-05 10:33:14.239] error: connect ECONNREFUSED 35.230.57.124:7870 Error: connect ECONNREFUSED 35.230.57.124:7870 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16) error Command failed with exit code 1.
Solution:
with that said, the issue is that you are trying to connect to your deprecated and shut down legacy database, please read this docs page https://docs.railway.app/guides/database-migration-guide#switching-over-connections...
Jump to solution
22 Replies
Percy
Percy5mo ago
Project ID: b5bfdc68-e6f6-4a25-903c-7ccd329c8f97
Blackbeak
Blackbeak5mo ago
Project ID: b5bfdc68-e6f6-4a25-903c-7ccd329c8f97 MOre to the point despite the crashes why would it suddenly do this? I can investigate myself if I know where to start. Anyone in Railway working today? Am I doing something against the rules here? I have been waiting all day for some kind of support.
Brody
Brody5mo ago
hey sorry for not being able to get to this thread sooner, but this is community support.
Blackbeak
Blackbeak5mo ago
No worries.
Solution
Brody
Brody5mo ago
with that said, the issue is that you are trying to connect to your deprecated and shut down legacy database, please read this docs page https://docs.railway.app/guides/database-migration-guide#switching-over-connections
Blackbeak
Blackbeak5mo ago
I changed all the variables in Strapi to match earlier today. Still no luck. Same issue. And why did it work yeasterday? I was under the assumption on Jan 31st the old legacy DB would shut down.
Brody
Brody5mo ago
the legacy databases are shut down in waives, it would create far too much support load if they where all shut down at the same time please look for any hardcoded database credentials and update them to use environment variables in conjunction with variable references
Blackbeak
Blackbeak5mo ago
your reference variables page is "page not found" in your docs.
Brody
Brody5mo ago
oh wow, good catch
Blackbeak
Blackbeak5mo ago
Still having trouble with this so let me know if this is updated. I recognise it's my connection errors but I am having difficulty setting it up right.
Brody
Brody5mo ago
my bad, this is the section the docs should have taken you to https://docs.railway.app/guides/variables#reference-variables
Blackbeak
Blackbeak5mo ago
Ok, that's confusing me evn more. 🙂 I have a local .env file that matches what is in Railway's new server and I am referencing them there. Is this what I am doing wrong?
Blackbeak
Blackbeak5mo ago
IE the variables here;
No description
Blackbeak
Blackbeak5mo ago
match my .env file and I reference them from strapi like so; module.exports = ({ env }) => ({ connection: { client: 'postgres', connection: { host: env('PGHOST'), port: env.int('PGPORT'), database: env('PGDATABASE'), user: env('PGUSER'), password: env('PGPASSWORD'), }, }, }); i thought this would be enough as there are no hard coded vars there?
Brody
Brody5mo ago
this is an example of what the raw variables for your database would look like on your app's service (assuming your database service is named Postgres)
PGDATABASE=${{Postgres.PGDATABASE}}
PGUSER=${{Postgres.PGUSER}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGHOST=${{Postgres.PGHOST}}
PGPORT=${{Postgres.PGPORT}}
PGDATABASE=${{Postgres.PGDATABASE}}
PGUSER=${{Postgres.PGUSER}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGHOST=${{Postgres.PGHOST}}
PGPORT=${{Postgres.PGPORT}}
Blackbeak
Blackbeak5mo ago
So I update my .env to look like the above?
Brody
Brody5mo ago
nope, those are for railway
Brody
Brody5mo ago
No description
Blackbeak
Blackbeak5mo ago
Ahh ok. So I update them here;
No description
Brody
Brody5mo ago
im seeing a hardcoded database url but you dont use that in code from what you have shown me, so you can just remove that
Blackbeak
Blackbeak5mo ago
Ok. Thanks. That's where I was going wrong. I didn't understand the railway vars needed changing. So hardcoded variables there were the problem not in my app. Service is back up and running now. Thanks for the support. You can close this.
Brody
Brody5mo ago
happy to help!