Gcloud n8n startup very slow - selfhosted

Hi,

I’ve created a docker file for a google cloud deployment.
It works, but the starting process is very slow.

it tooks minutes.

i’m using theese env variables:

# db
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=/cloudsql/<NAME>
DB_POSTGRESDB_DATABASE=stage_n8n_backend
DB_POSTGRESDB_PASSWORD=<secret>

# other
N8N_HOST=https://<NAME>.europe-west1.run.app
WEBHOOK_URL=https://<NAME>.europe-west1.run.app
N8N_EDITOR_BASE_URL=https://<NAME>.europe-west1.run.app
N8N_ENCRYPTION_KEY=<KEY>
N8N_PROTOCOL=https
GENERIC_TIMEZONE=Europe/Berlin
N8N_VERSION_NOTIFICATIONS_ENABLED=false
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
NODE_FUNCTION_ALLOW_EXTERNAL=uuid
N8N_RUNNERS_ENABLED=true
N8N_LOG_LEVEL=debug

the google cloud config is:

  # Deploy container image to Cloud Run
  - name: 'gcr.io/cloud-builders/gcloud'
    args: [ 'run', 'deploy', 'stage-n8n-admin',
            '--source', '.',
            '--region', 'europe-west1',
            '--min-instances', '0',
            '--max-instances', '1',
            '--concurrency', 'default',
            '--memory', '2048Mi',
            '--concurrency', 'default',
            '--timeout', '180',
            '--allow-unauthenticated',
            '--cpu-throttling',
            '--cpu-boost',
            '--execution-environment', 'gen2',
            '--port', '5678',
            '--set-cloudsql-instances', '<NAME>',
            '--set-secrets', '^|^DB_POSTGRESDB_PASSWORD=STAGE__N8N_DATABASE_PASSWORD:latest',
            '--env-vars-file', 'gcloud_build/stage.yml'

the database is also hosted by google.

i see many issue like this:

2025-06-19 10:42:53.062 MESZ
10:42:53.062 e[31merrore[39m e[31mConnection terminated due to connection timeoute[39m { "file": "error-reporter.js", "function": "defaultReport" }
2025-06-19 10:42:53.062 MESZ
10:42:53.062 e[31merrore[39m e[31mConnection terminated unexpectedlye[39m { "file": "error-reporter.js", "function": "defaultReport" }
2025-06-19 10:43:18.362 MESZ
10:43:18.361 e[34mdebuge[39m e[34mQuerying database for waiting executionse[39m { "scopes": ["waiting-executions"], "file": "wait-tracker.js", "function": "getWaitingExecutions" }
2025-06-19 10:43:34.369 MESZ
10:43:34.360 e[31merrore[39m e[31mConnection terminated due to connection timeoute[39m { "file": "error-reporter.js", "function": "defaultReport" }
2025-06-19 10:43:34.369 MESZ
10:43:34.360 e[31merrore[39m e[31mConnection terminated unexpectedlye[39m { "file": "error-reporter.js", "function": "defaultReport" }
2025-06-19 10:43:40.061 MESZ
10:43:40.061 e[31merrore[39m e[31mConnection terminated due to connection timeoute[39m { "file": "error-reporter.js", "function": "defaultReport" }
2025-06-19 10:43:40.061 MESZ
10:43:40.061 e[31merrore[39m e[31mConnection terminated unexpectedlye[39m { "file": "error-reporter.js", "function": "defaultReport" }

but the database is there and in some cases it works.

I’ve no idea.

please help me :slight_smile:
Thanks

you might be using a very small machine instance with very less cpu and ram. Try vertically scaling by going to a different instance with bigger size and that should help