Where do you host Strapi?

I’m using railway too, with full satisfaction and very reasonable fees.

I’ll check out Railway … sounds like a good deal!

1 Like

I just move to Railway and love it so far.

1 Like

Has anyone come across crashes on Railway?

I love it and use it for a few other apps – Has anyone else experienced overnight crashes like this:

[2022-03-15 12:35:58.174] debug: ⛔️ Server wasn't able to start properly.

[2022-03-15 12:35:58.174] error: select "t0"."id" from "admin_users" as "t0" limit $1 - Connection terminated unexpectedly

Error: select "t0"."id" from "admin_users" as "t0" limit $1 - Connection terminated unexpectedly

at Connection. (/app/node_modules/pg/lib/client.js:132:73)

Really struggling to find a solution for it – any help would be great!!

2 Likes

Can you slso store images on the Railway servers or will assets be deleted like on Heroku?

Im not sure, never tried. It shouldn’t delete any files as on railway.app your app doesn’t sleep.

But it would be stupid to host files there as it would consume your bandwidth and its better to host on some bucket with cdn. Like s3, or buckblaze

edit: on buckblaze you have 10GB free and if you proxy it with cloudflare you dont pay for bandwith
here is tutorial how to setup BuckBlaze bucket with cloudflare CDN, also you can use Strapi AWS S3 to upload images/files in buckblaze bucket only thing you will need at moment is edit link on your frontend as for now strapi doesnt have cdn links.

this is my setup in plugins.js so that allows me to upload to BuckBlaze B2 bucket using AWS-S3 provider. at moment CDN parametar is not working when i deploy it as i customized it, and its not uploaded when i deploy it, be we all hope that Strapi will soon allow CDN for all upload providers.

upload: {
    config: {
      provider: 'aws-s3',
      providerOptions: {
        accessKeyId: process.env.C1_backblaze_keyID,
        secretAccessKey: process.env.C2_backblaze_applicationKey,
        region: process.env.C3_backblaze_region,
        params: {
           Bucket: process.env.C4_backblaze_keyName,
         },
        endpoint:process.env.C5_endpoint, //workings
        baseUrl: process.env.C6_CDN,
      },
    },
  },

EDIT 2: if you are using my setup like here on top. you can add custom plugin and in src/plugins/<your-plugin-name>/server/bootstrap.js add this:

'use strict';
module.exports = ({ strapi }) => {
  // bootstrap phase
  strapi.db.lifecycles.subscribe({
    models: ['plugin::upload.file'],

    // your lifecycle hooks

    //
    async beforeCreate(event) {
      const { params } = event;
      if(!!strapi.config.get('plugin.upload.providerOptions.baseUrl')){
        params.data.url="https://"+strapi.config.get('plugin.upload.providerOptions.baseUrl')+'/'+params.data.hash+params.data.ext
        if(!!params.data.formats){
          if(!!params.data.formats.thumbnail){
            params.data.formats.thumbnail.url="https://"+strapi.config.get('plugin.upload.providerOptions.baseUrl')+'/'+params.data.formats.thumbnail.hash+params.data.formats.thumbnail.ext
          }
          if(!!params.data.formats.large){
            params.data.formats.large.url="https://"+strapi.config.get('plugin.upload.providerOptions.baseUrl')+'/'+params.data.formats.large.hash+params.data.formats.large.ext
          }
          if(!!params.data.formats.medium){
            params.data.formats.medium.url="https://"+strapi.config.get('plugin.upload.providerOptions.baseUrl')+'/'+params.data.formats.medium.hash+params.data.formats.medium.ext
          }
          if(!!params.data.formats.small){
            params.data.formats.small.url="https://"+strapi.config.get('plugin.upload.providerOptions.baseUrl')+'/'+params.data.formats.small.hash+params.data.formats.small.ext
          }
        }
      }
    },
  }),
};

and you will have cdn link for your images. now only thing you need to do is add your cdn link in your security. LINK

3 Likes

Hi! Did you find a solution for this?

I am experiencing this, too.

Using Render.com with starter plan

C4_backblaze_keyName is a bit misleading… it should be the bucket name, as the parameters says. Got it working, many thanks!

Also is it possible to decide which URL should be in the database? I want to use a subdomain on my website rather than the Blackblaze one.

Is there any solution for this issue other than increase server capacity until it never happens any more? I host strapi on an render.com instance and this error randomly appears. Even on the local dev environment with docker this happens.
Locally and on render ist not that much user traffic, maybe two users at the same time. This can’t be too much.

Looking for some help

Static content like images/videos should go into an S3(-compatible) bucket (or something similar). This allows you to host Strapi in a high available (HA) setup (> 1 instance). If you are not familiar with infrastructure deployment try an ‘app platform’ that several different providers offer. Otherwise, Kubernetes is always a very flexible and scalable way to deploy containerized environments. Both are available at DigitalOcean.

Hope this helps!

parameter names are ones that i use.
Post is updated with new info, if you follow it and understand it you can have. upload to s3 bucket, and proxy throw cloudflare if you edited cloudflare transform rules like described in link provided in post.

In latest update if you add custom plugin you can have url edited on upload and you will have proxied url in database. it can be domain/subdomain depending how you edited cloudflare rules

I’ve used Digital Ocean and Linode to host Strapi with great success. They have managed databases, but if your db is small, you can host the db on the same virtual or dedicated hardware as Strapi.

1 Like

Did you try boosting your plan?

Yep – I’m on the developer plan and definitely paying for it, got 7 other projects running on it fine and only my two Strapi environments are the ones running into problems.

I’ll need more input from more database-minded people… but considering on playing with some of the connection parameters like connection timeouts (tcp_user_timeout) etc

Or switch the database out for a different provider and see if that solves it :man_shrugging:

Have you had any luck / experience similar / have a plan of attack?

I see, I said that because I think I already saw the error message from when I was on a development plan on Platform.sh, also found other people mentioning that on StackOverflow.

I also experienced some crashing on railway but it seems fixed now on my strapi instance which shows good uptime. This may coincide with me adding a credit card, but it doesn’t charge you until you exceed $10 which i haven’t yet.

Assets need to be stored outside of railway, but the default starter has config variables for Cloudinary so that’s the easiest way to go, though I may swap out to supabase storage and db.

Thankfully railway is really versatile this way because each service is modular.

Hi danfascia,

I’am trying to deploy strapi on railway from starters. May I know how you configured env variables? I’m new to strapi. A blog post for reference would be appreciated.

Regards
Shreyash

When you deploy the starter in the railway control panel it gives you a comprehensive wizard style dialog to enter all of your ENV variables.

Some of them you just make up yourself like the keys, others are from integrations such as Cloudinary if you use it.

It’s very easy to get up and running.

The main issue is I can’t get it to run in development mode using ENV variables so once deployed, I change the run command to npm run develop

I’m having the same issue with the standard plus plan (3gb RAM, 1.5 CPU) which means it can’t be a performance issue, can it?

Also Railway. I like it.