Strapi server + Postgres DB deploy on railway crashes
frankiefab100
TRIALOP

a year 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

a year ago

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


medim
MODERATOR

a year ago

Are you using the template?



frankiefab100
TRIALOP

a year ago

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


frankiefab100
TRIALOP

a year ago

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


medim
MODERATOR

a year ago

Please check the DB credentials


medim
MODERATOR

a year ago

Check if strapi is using the correct ones


frankiefab100
TRIALOP

a year ago

Everything works locally but not in production.


frankiefab100
TRIALOP

a year ago

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


milo
MODERATOR

a year ago

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


frankiefab100
TRIALOP

a year ago

If you are willing to show me how to


milo
MODERATOR

a year ago

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


medim
MODERATOR

a year 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"


medim
MODERATOR

a year ago

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


frankiefab100
TRIALOP

a year ago

No


frankiefab100
TRIALOP

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


brody
EMPLOYEE

a year ago

either way, the project you linked has been deleted


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

f9380294-0728-419c-b3e5-3a7d4901d233


brody
EMPLOYEE

a year 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

a year ago

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


brody
EMPLOYEE

a year ago

link to frontend please?


frankiefab100
TRIALOP

a year ago

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


frankiefab100
TRIALOP

a year ago

https://frankiefab.vercel.app/projects

Here is the page where the strapi content should display.


frankiefab100
TRIALOP

a year 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

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

Yes, I saw it

1329580322677063700


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

I see nothing. It looks like they were deleted


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

I get this error when I try to

1329605704872497200


frankiefab100
TRIALOP

a year ago

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

1329605971818840000


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


frankiefab100
TRIALOP

a year ago

Still getting the same error messages


frankiefab100
TRIALOP

a year ago

Used Host:postgres. it didn’t work too


brody
EMPLOYEE

a year 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

a year ago

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

1329754770067554300


brody
EMPLOYEE

a year 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

a year ago

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

1329943159601627100


brody
EMPLOYEE

a year ago

you need to use the TCP proxy


frankiefab100
TRIALOP

a year ago

xxxxx.rlwy.net:12345??


brody
EMPLOYEE

a year ago

yes


frankiefab100
TRIALOP

a year ago

This should require use of websocket.


frankiefab100
TRIALOP

a year ago

This url display: Application failed to respond


brody
EMPLOYEE

a year ago

postgres does not use WebSockets


brody
EMPLOYEE

a year ago

connect to the database with [viaduct.proxy.rlwy.net:17157](viaduct.proxy.rlwy.net:17157)


frankiefab100
TRIALOP

a year ago

Doesn't work😔


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

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


frankiefab100
TRIALOP

a year ago

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


brody
EMPLOYEE

a year ago

this is why the community has recommended you the template -

please read its overview and look at how its setup -


brody
EMPLOYEE

a year ago

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


brody
EMPLOYEE

a year ago

!s


Status changed to Solved brody about 1 year ago


Loading...