Strapi server + Postgres DB deploy on railway crashes
frankiefab100
TRIALOP

2 years ago

The strapi app deployed successfully, crashes after 5 seconds and the restarts. I have added all the necessary Postgres Variables and update config/database.ts still it doesn’t work.

Solved

66 Replies

frankiefab100
TRIALOP

2 years ago

Project Id: 18412832-e50f-40f0-8b15-650eaf03ec65


2 years ago

Are you using the template?



frankiefab100
TRIALOP

2 years ago

No, the strapi version is old and I don’t know how to use it


frankiefab100
TRIALOP

2 years ago

I deployed my project on railway and deployed a new Postgres for the project


2 years ago

Please check the DB credentials


2 years ago

Check if strapi is using the correct ones


frankiefab100
TRIALOP

2 years ago

Everything works locally but not in production.


frankiefab100
TRIALOP

2 years ago

In database.ts: there are configs like PGHOST, PGDATABASE etc but environment variables are DATABASE_HOST, DATABASE_NAME. Which is the right one to use


2 years ago

just updated it to use latest, do you want to give that a go?


frankiefab100
TRIALOP

2 years ago

If you are willing to show me how to


2 years ago

https://railway.com/template/strapi all instructions r here


2 years ago

Yeah, because locally ur postgres instance has other creds, ur trying to log in with "root" while the default user on the railway postgres db is "postgres"


2 years ago

Anyway, did u manage to deploy it through the template @frankiefab ?


frankiefab100
TRIALOP

2 years ago

No


frankiefab100
TRIALOP

2 years ago

Using this template requires me create new content types and documents on strapi


frankiefab100
TRIALOP

2 years ago

I can’t tell why the developer relations team at Railway suggest this same template for every problem. There should a better solution


2 years ago

hello, these people are community members and moderators, them recommending something that is known working is a good recommendation.


2 years ago

either way, the project you linked has been deleted


frankiefab100
TRIALOP

2 years ago

I know, I mean not here, in Railway forum.


2 years ago

would you like to provide a new project id for me to look into?


frankiefab100
TRIALOP

2 years ago

f9380294-0728-419c-b3e5-3a7d4901d233


2 years ago

alright fixed it up for you, you can look at your activity logs to see what i needed to do to fix your project up


frankiefab100
TRIALOP

2 years ago

Thank you. But any reason why the strapi content still doesn’t show up on the frontend even after successful deployment.


2 years ago

link to frontend please?


frankiefab100
TRIALOP

2 years ago

Seems I will need to update config/database.ts to match the Postgres env. variables


frankiefab100
TRIALOP

2 years ago

https://frankiefab.vercel.app/projects

Here is the page where the strapi content should display.


frankiefab100
TRIALOP

2 years ago

I already create config/env/production/database.ts:


module.exports = ({ env }) => ({
    connection: {
        client: 'postgres',
        connection: {
            host: env('PGHOST', '127.0.0.1'),
            port: env.int('PGPORT', 5931),
            database: env('PGDATABASE', 'railway'),
            user: env('PGUSER', 'postgres'),
            password: env('PGPASSWORD', 'password'),
            ssl: env.bool(true),
        },
    },
});

frankiefab100
TRIALOP

2 years ago

Didn’t make any changes to the default “config/database.ts”


2 years ago

nope, i aleady set the needed variables, please look at the changes i made in your activity tab


frankiefab100
TRIALOP

2 years ago

Yes, I saw it

1329580322677063690


2 years ago

this page is not makeing an api request to strapi to begin with


frankiefab100
TRIALOP

2 years ago

When the STRAPI_URL is already updated in the client side fetch request


2 years ago

have you logged into your strapi /admin pannel and made sure the needed data is there?


frankiefab100
TRIALOP

2 years ago

I see nothing. It looks like they were deleted


2 years ago

i'm sorry but i can't help with deleted data


frankiefab100
TRIALOP

2 years ago

I just run strapi locally via localhost:1337/admin. I see the contents.


frankiefab100
TRIALOP

2 years ago

But it doesn’t show nothing shows in the deployed strapi-railway url


2 years ago

when you develop locally, are you connecting to the postgres database on railway?


frankiefab100
TRIALOP

2 years ago

I don’t think so, just the default strapi MSQLite.


2 years ago

then of course there isnt going to be any data when you deploy to railway


frankiefab100
TRIALOP

2 years ago

I get this error when I try to

1329605704872497244


frankiefab100
TRIALOP

2 years ago

This too. After updating config/database.ts to connect to Postgres on railway

1329605971818840186


2 years ago

you need to use the public host and port when connecting to the database locally


frankiefab100
TRIALOP

2 years ago

Port is 5432, Host is my strapi server.railway.app??


frankiefab100
TRIALOP

2 years ago

Still getting the same error messages


frankiefab100
TRIALOP

2 years ago

Used Host:postgres. it didn’t work too


2 years ago

Neither of those are the public host or port, you can find the public host and port of your database under its public networking section


frankiefab100
TRIALOP

2 years ago

This. But on railway the Postgres port is 5432 and Public host points to DATABASE_PUBLIC_URL which is different too. Sorry, this can be confusing. Do I need to update the Postgres variables again since the Strapi variables references it.

1329754770067554304


2 years ago

that is the public domain of your app, please look at the public networking section of the database, and please do not modify any variables on railway again as I have set them how they need to be


frankiefab100
TRIALOP

2 years ago

This doesn’t work too. I can’t access the url.

1329943159601627238


2 years ago

you need to use the TCP proxy


frankiefab100
TRIALOP

2 years ago

xxxxx.rlwy.net:12345??


2 years ago

yes


frankiefab100
TRIALOP

2 years ago

This should require use of websocket.


frankiefab100
TRIALOP

2 years ago

This url display: Application failed to respond


2 years ago

postgres does not use WebSockets


2 years ago

connect to the database with viaduct.proxy.rlwy.net:17157


frankiefab100
TRIALOP

2 years ago

Doesn't work😔


2 years ago

it does, the data tab can connect to it, and the data tab uses that host and port


frankiefab100
TRIALOP

2 years ago

You mean it now works as the STRAPI URL? Nothing still shows up.here


2 years ago

when you develop locally you need to have strapi connect to the database on railway


frankiefab100
TRIALOP

2 years ago

Any helpful resources. What needs to be updated in config/database or config/server


2 years ago

this is why the community has recommended you the template -

please read its overview and look at how its setup -


2 years ago

going to mark this as solved now that you have all the resources you need to succeed now!


2 years ago

!s


Status changed to Solved brody • over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...