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:Jump to 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...
22 Replies
Project ID:
b5bfdc68-e6f6-4a25-903c-7ccd329c8f97
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.
hey sorry for not being able to get to this thread sooner, but this is community support.
No worries.
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
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.
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
your reference variables page is "page not found" in your docs.
oh wow, good catch
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.
my bad, this is the section the docs should have taken you to https://docs.railway.app/guides/variables#reference-variables
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?
IE the variables here;
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?
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
)
So I update my .env to look like the above?
nope, those are for railway
Ahh ok. So I update them here;
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
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.
happy to help!