Redis and Broker Connection Issues in n8n Queue Mode (Cloud Run Deployment)

Describe the problem/error/question

I’m trying to set up the following architecture:

  • n8n in queue mode (main + workers)

  • Redis for queuing (deployed in Memorystore)

  • PostgreSQL for persistence

  • Google Cloud Run for deployment

    • With VPC connector attached

Everything runs in GCP, with Redis hosted on a private IP within the same VPC.

I have the following env vars:

DB_TYPE=postgresdb

DB_POSTGRESDB_HOST=Cloud Sql host

DB_POSTGRESDB_PORT=5432

DB_POSTGRESDB_DATABASE=n8n

DB_POSTGRESDB_USER=n8n-user

EXECUTIONS_MODE=queue

N8N_DEPLOYMENT_TYPE=main

N8N_RUNNERS_ENABLED=true

N8N_BASIC_AUTH_ACTIVE=true

N8N_BASIC_AUTH_USER=user

N8N_BASIC_AUTH_PASSWORD=password

N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false

N8N_HOST=0.0.0.0

N8N_PORT=5678

WEBHOOK_URL=https://XXXXXX.europe-west3.run.app

N8N_EDITOR_BASE_URL=https://XXXXXX.europe-west3.run.app

N8N_RUNNER_AUTH_MODE=service

N8N_RUNNER_AUTH_TOKEN=super-secret-token

QUEUE_MODE=redis

QUEUE_BULL_REDIS_HOST=Redis Private IP

QUEUE_BULL_REDIS_PORT=6379

OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true

Dockerfile

FROM n8nio/n8n:latest

# Copy the script and ensure it has proper permissions

USER root

COPY startup.sh /

RUN chmod +x /startup.sh

USER node

EXPOSE 5678

startup.sh

#!/bin/sh

# Print environment variables for debugging

echo “Database settings:”

echo “DB_TYPE: $DB_TYPE”

echo “DB_POSTGRESDB_DATABASE: $DB_POSTGRESDB_DATABASE”

echo “DB_POSTGRESDB_USER: $DB_POSTGRESDB_USER”

echo “DB_POSTGRESDB_HOST: $DB_POSTGRESDB_HOST”

echo “DB_POSTGRESDB_PORT: $DB_POSTGRESDB_PORT”

echo “N8N_BASIC_AUTH_ACTIVE: $N8N_BASIC_AUTH_ACTIVE”

echo “N8N_BASIC_AUTH_USER: $N8N_BASIC_AUTH_USER”

echo “N8N_DEPLOYMENT_TYPE: $N8N_DEPLOYMENT_TYPE”

echo “N8N_RUNNERS_ENABLED: $N8N_RUNNERS_ENABLED”

echo “N8N_HOST: $N8N_HOST”

echo “N8N_PORT: $N8N_PORT”

echo “WEBHOOK_URL: $WEBHOOK_URL”

echo “PORT: $PORT”

echo “QUEUE_MODE: $QUEUE_MODE”

echo “QUEUE_BULL_REDIS_HOST: $QUEUE_BULL_REDIS_HOST”

echo “QUEUE_BULL_REDIS_PORT: $QUEUE_BULL_REDIS_PORT”

echo “:test_tube: Checking Redis connectivity at $QUEUE_BULL_REDIS_HOST:$QUEUE_BULL_REDIS_PORT…”

# Try to connect to Redis (max 5 attempts)

for i in {1..5}; do

if nc -z “$QUEUE_BULL_REDIS_HOST” “$QUEUE_BULL_REDIS_PORT”; then

echo “:white_check_mark: Redis is reachable!”

break

else

echo “:cross_mark: Attempt $i: Cannot connect to Redis at $QUEUE_BULL_REDIS_HOST:$QUEUE_BULL_REDIS_PORT”

sleep 2

fi

done

# Final check after retries

if ! nc -z “$QUEUE_BULL_REDIS_HOST” “$QUEUE_BULL_REDIS_PORT”; then

echo “:prohibited: Failed to connect to Redis after retries. Exiting.”

exit 1

fi

# Start n8n

echo “:rocket: Starting n8n…”

# Start n8n with its original entrypoint

exec /docker-entrypoint.sh

# Use shell form to help avoid exec format issues

ENTRYPOINT [“/bin/sh”, “/startup.sh”]

What is the error message (if any)?

I get Cannot GET / in the app endpoint https://XXXXXX.europe-west3.run.app

Env variables seem to be correctly set, but Redis connection times out and it doesn’t seem to use Redis queue based on n8n Task Broker ready on 127.0.0.1, port 5679.

Considerations:

  • Redis is reachable using nc or startup script in a different container.
  • n8n fails to maintain connection to Redis.
  • I’ve tried to use .n8n/settings.js to force config (copied into Docker image at /home/node/.n8n/settings.js) and changed to N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true, but it didn’t work either.
  • I’ve set N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0 in main instance, but it didn’t change anything.

Information on your n8n setup

  • n8n version: 1.103.2
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Cloud Run
  • Operating system: