[GH-ISSUE #4643] [bug]: RangeError: Invalid key length #1718

Closed
opened 2026-03-16 21:31:25 +03:00 by kerem · 3 comments
Owner

Originally created by @Nifleheim on GitHub (Dec 24, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4643

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Current behavior
When I try to run the app through docker compose, I get this error in the backend app:

hopps-hoppscotch-backend-1   | Backend Server | Initialize PubSub
hopps-hoppscotch-backend-1   | Backend Server | RangeError: Invalid key length
hopps-hoppscotch-backend-1   | Backend Server |     at Cipheriv.createCipherBase (node:internal/crypto/cipher:121:19)
hopps-hoppscotch-backend-1   | Backend Server |     at Cipheriv.createCipherWithIV (node:internal/crypto/cipher:140:3)
hopps-hoppscotch-backend-1   | Backend Server |     at new Cipheriv (node:internal/crypto/cipher:243:3)
hopps-hoppscotch-backend-1   | Backend Server |     at Object.createCipheriv (node:crypto:147:10)
hopps-hoppscotch-backend-1   | Backend Server |     at encrypt (/dist/backend/dist/utils.js:151:27)
hopps-hoppscotch-backend-1   | Backend Server |     at getDefaultInfraConfigs (/dist/backend/dist/infra-config/helper.js:98:40)
hopps-hoppscotch-backend-1   | Backend Server |     at InfraConfigService.initializeInfraConfigTable (/dist/backend/dist/infra-config/infra-config.service.js:58:83)
hopps-hoppscotch-backend-1   | Backend Server |     at InfraConfigService.onModuleInit (/dist/backend/dist/infra-config/infra-config.service.js:54:20)
hopps-hoppscotch-backend-1   | Backend Server |     at MapIterator.iteratee (/dist/backend/node_modules/.pnpm/@nestjs+core@10.4.4_@nestjs+common@10.4.4_class-transformer@0.5.1_class-validator@0.14.1_refl_uclmhdhodpinoxc7fwisrergn4/node_modules/@nestjs/core/hooks/on-module-init.hook.js:22:43)
hopps-hoppscotch-backend-1   | Backend Server |     at MapIterator.next (/dist/backend/node_modules/.pnpm/iterare@1.2.1/node_modules/iterare/lib/map.js:13:39) {
hopps-hoppscotch-backend-1   | Backend Server |   code: 'ERR_CRYPTO_INVALID_KEYLEN'
hopps-hoppscotch-backend-1   | Backend Server | }
hopps-hoppscotch-backend-1   | Backend Server | /dist/backend/dist/utils.js:26
hopps-hoppscotch-backend-1   | Backend Server |     throw new Error(errMessage);
hopps-hoppscotch-backend-1   | Backend Server |           ^
hopps-hoppscotch-backend-1   | Backend Server | 
hopps-hoppscotch-backend-1   | Backend Server | Error: RangeError: Invalid key length
hopps-hoppscotch-backend-1   | Backend Server |     at throwErr (/dist/backend/dist/utils.js:26:11)
hopps-hoppscotch-backend-1   | Backend Server |     at InfraConfigService.initializeInfraConfigTable (/dist/backend/dist/infra-config/infra-config.service.js:98:38)
hopps-hoppscotch-backend-1   | Backend Server |     at async InfraConfigService.onModuleInit (/dist/backend/dist/infra-config/infra-config.service.js:54:9)
hopps-hoppscotch-backend-1   | Backend Server | 
hopps-hoppscotch-backend-1   | Backend Server | Node.js v20.18.1
hopps-hoppscotch-backend-1   | Exiting process because Backend Server exited with code 1
hopps-hoppscotch-backend-1 exited with code 1

.env file :

# -----------------------Backend Config------------------------------#
# Prisma Config
DATABASE_URL=postgresql://user:pass@aws-rds:5432/hoppscotch

# Auth Tokens Config
JWT_SECRET=secretcode123
TOKEN_SALT_COMPLEXITY=10
MAGIC_LINK_TOKEN_VALIDITY=3
REFRESH_TOKEN_VALIDITY=604800000
ACCESS_TOKEN_VALIDITY=86400000
SESSION_SECRET=anothersecretcode123

DATA_ENCRYPTION_KEY=8GMsSBBY9KMQpq1sM+5+ZkU68W1jNhnMfpgzpZsZiro=

# Hoppscotch App Domain Config
REDIRECT_URL=http://localhost:3000
WHITELISTED_ORIGINS=http://localhost:3170,http://localhost:3000,http://localhost:3100
VITE_ALLOWED_AUTH_PROVIDERS=GITHUB

# Github Auth Config
GITHUB_CLIENT_ID=redacted
GITHUB_CLIENT_SECRET=redacted
GITHUB_CALLBACK_URL=http://localhost:3170/v1/auth/github/callback
GITHUB_SCOPE=mygithubaccount:personalemail

# Mailer config
MAILER_ADDRESS_FROM=personalemail
MAILER_SMTP_URL=smtps://localhost:1025

# Rate Limit Config
RATE_LIMIT_TTL=60
RATE_LIMIT_MAX=100

# -----------------------Frontend Config------------------------------#

# Base URLs
VITE_BASE_URL=http://localhost:3000
VITE_SHORTCODE_BASE_URL=http://localhost:3000
VITE_ADMIN_URL=http://localhost:3100

# Backend URLs
VITE_BACKEND_GQL_URL=http://localhost:3170/graphql
VITE_BACKEND_WS_URL=wss://localhost:3170/graphql
VITE_BACKEND_API_URL=http://localhost:3170/v1

# Terms Of Service And Privacy Policy Links (Optional)
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy

ENABLE_SUBPATH_BASED_ACCESS=false

docker-compose:

services:
  hoppscotch-frontend:
    image: hoppscotch/hoppscotch-frontend
    ports:
      - 3000:3000
    env_file: .env
    restart: always
  hoppscotch-backend:
    image: hoppscotch/hoppscotch-backend
    ports:
      - 3170:3170
    env_file: .env
    restart: always
  hoppscotch-admin:
    image: hoppscotch/hoppscotch-admin
    ports:
      - 3100:3100
    env_file: .env
    restart: always
networks: {}

```


 

### Steps to reproduce

1. install self hosted version with latest images
2. update env file
3. see the error logs

### Environment

Production

### Version

Self-hosted
Originally created by @Nifleheim on GitHub (Dec 24, 2024). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4643 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior **Current behavior** When I try to run the app through docker compose, I get this error in the backend app: ``` hopps-hoppscotch-backend-1 | Backend Server | Initialize PubSub hopps-hoppscotch-backend-1 | Backend Server | RangeError: Invalid key length hopps-hoppscotch-backend-1 | Backend Server | at Cipheriv.createCipherBase (node:internal/crypto/cipher:121:19) hopps-hoppscotch-backend-1 | Backend Server | at Cipheriv.createCipherWithIV (node:internal/crypto/cipher:140:3) hopps-hoppscotch-backend-1 | Backend Server | at new Cipheriv (node:internal/crypto/cipher:243:3) hopps-hoppscotch-backend-1 | Backend Server | at Object.createCipheriv (node:crypto:147:10) hopps-hoppscotch-backend-1 | Backend Server | at encrypt (/dist/backend/dist/utils.js:151:27) hopps-hoppscotch-backend-1 | Backend Server | at getDefaultInfraConfigs (/dist/backend/dist/infra-config/helper.js:98:40) hopps-hoppscotch-backend-1 | Backend Server | at InfraConfigService.initializeInfraConfigTable (/dist/backend/dist/infra-config/infra-config.service.js:58:83) hopps-hoppscotch-backend-1 | Backend Server | at InfraConfigService.onModuleInit (/dist/backend/dist/infra-config/infra-config.service.js:54:20) hopps-hoppscotch-backend-1 | Backend Server | at MapIterator.iteratee (/dist/backend/node_modules/.pnpm/@nestjs+core@10.4.4_@nestjs+common@10.4.4_class-transformer@0.5.1_class-validator@0.14.1_refl_uclmhdhodpinoxc7fwisrergn4/node_modules/@nestjs/core/hooks/on-module-init.hook.js:22:43) hopps-hoppscotch-backend-1 | Backend Server | at MapIterator.next (/dist/backend/node_modules/.pnpm/iterare@1.2.1/node_modules/iterare/lib/map.js:13:39) { hopps-hoppscotch-backend-1 | Backend Server | code: 'ERR_CRYPTO_INVALID_KEYLEN' hopps-hoppscotch-backend-1 | Backend Server | } hopps-hoppscotch-backend-1 | Backend Server | /dist/backend/dist/utils.js:26 hopps-hoppscotch-backend-1 | Backend Server | throw new Error(errMessage); hopps-hoppscotch-backend-1 | Backend Server | ^ hopps-hoppscotch-backend-1 | Backend Server | hopps-hoppscotch-backend-1 | Backend Server | Error: RangeError: Invalid key length hopps-hoppscotch-backend-1 | Backend Server | at throwErr (/dist/backend/dist/utils.js:26:11) hopps-hoppscotch-backend-1 | Backend Server | at InfraConfigService.initializeInfraConfigTable (/dist/backend/dist/infra-config/infra-config.service.js:98:38) hopps-hoppscotch-backend-1 | Backend Server | at async InfraConfigService.onModuleInit (/dist/backend/dist/infra-config/infra-config.service.js:54:9) hopps-hoppscotch-backend-1 | Backend Server | hopps-hoppscotch-backend-1 | Backend Server | Node.js v20.18.1 hopps-hoppscotch-backend-1 | Exiting process because Backend Server exited with code 1 hopps-hoppscotch-backend-1 exited with code 1 ``` **.env file** : ``` # -----------------------Backend Config------------------------------# # Prisma Config DATABASE_URL=postgresql://user:pass@aws-rds:5432/hoppscotch # Auth Tokens Config JWT_SECRET=secretcode123 TOKEN_SALT_COMPLEXITY=10 MAGIC_LINK_TOKEN_VALIDITY=3 REFRESH_TOKEN_VALIDITY=604800000 ACCESS_TOKEN_VALIDITY=86400000 SESSION_SECRET=anothersecretcode123 DATA_ENCRYPTION_KEY=8GMsSBBY9KMQpq1sM+5+ZkU68W1jNhnMfpgzpZsZiro= # Hoppscotch App Domain Config REDIRECT_URL=http://localhost:3000 WHITELISTED_ORIGINS=http://localhost:3170,http://localhost:3000,http://localhost:3100 VITE_ALLOWED_AUTH_PROVIDERS=GITHUB # Github Auth Config GITHUB_CLIENT_ID=redacted GITHUB_CLIENT_SECRET=redacted GITHUB_CALLBACK_URL=http://localhost:3170/v1/auth/github/callback GITHUB_SCOPE=mygithubaccount:personalemail # Mailer config MAILER_ADDRESS_FROM=personalemail MAILER_SMTP_URL=smtps://localhost:1025 # Rate Limit Config RATE_LIMIT_TTL=60 RATE_LIMIT_MAX=100 # -----------------------Frontend Config------------------------------# # Base URLs VITE_BASE_URL=http://localhost:3000 VITE_SHORTCODE_BASE_URL=http://localhost:3000 VITE_ADMIN_URL=http://localhost:3100 # Backend URLs VITE_BACKEND_GQL_URL=http://localhost:3170/graphql VITE_BACKEND_WS_URL=wss://localhost:3170/graphql VITE_BACKEND_API_URL=http://localhost:3170/v1 # Terms Of Service And Privacy Policy Links (Optional) VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy ENABLE_SUBPATH_BASED_ACCESS=false ``` **docker-compose**: ```` services: hoppscotch-frontend: image: hoppscotch/hoppscotch-frontend ports: - 3000:3000 env_file: .env restart: always hoppscotch-backend: image: hoppscotch/hoppscotch-backend ports: - 3170:3170 env_file: .env restart: always hoppscotch-admin: image: hoppscotch/hoppscotch-admin ports: - 3100:3100 env_file: .env restart: always networks: {} ``` ### Steps to reproduce 1. install self hosted version with latest images 2. update env file 3. see the error logs ### Environment Production ### Version Self-hosted
kerem 2026-03-16 21:31:25 +03:00
Author
Owner

@mirarifhasan commented on GitHub (Dec 25, 2024):

@Nifleheim
DATA_ENCRYPTION_KEY has to be exactly 32 characters long.

<!-- gh-comment-id:2561611018 --> @mirarifhasan commented on GitHub (Dec 25, 2024): @Nifleheim `DATA_ENCRYPTION_KEY` has to be exactly 32 characters long.
Author
Owner

@wliwan commented on GitHub (Mar 27, 2025):

I set it as 32 characters, but this issue still appears. like : DATA_ENCRYPTION_KEY="MAjIhv/ZqjLrCXeRTtRLNRI+8H4x3PFC"

<!-- gh-comment-id:2757836482 --> @wliwan commented on GitHub (Mar 27, 2025): I set it as 32 characters, but this issue still appears. like : DATA_ENCRYPTION_KEY="MAjIhv/ZqjLrCXeRTtRLNRI+8H4x3PFC"
Author
Owner

@ohko commented on GitHub (Aug 18, 2025):

I set it as 32 characters, but this issue still appears. like : DATA_ENCRYPTION_KEY="MAjIhv/ZqjLrCXeRTtRLNRI+8H4x3PFC"

remote the double quotation marks, like this: DATA_ENCRYPTION_KEY=12345678901234567890123456789012

<!-- gh-comment-id:3194886202 --> @ohko commented on GitHub (Aug 18, 2025): > I set it as 32 characters, but this issue still appears. like : DATA_ENCRYPTION_KEY="MAjIhv/ZqjLrCXeRTtRLNRI+8H4x3PFC" remote the double quotation marks, like this: DATA_ENCRYPTION_KEY=12345678901234567890123456789012
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1718
No description provided.