PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
21.31k stars 1.27k forks source link

Plugin Server Fails to Start on Fresh Self-Hosted Docker Install (Ubuntu 24.04) #25373

Open switchp0rt opened 4 days ago

switchp0rt commented 4 days ago

Bug Description

Plugin Server Fails to Start on Fresh Self-Hosted Docker Install (Ubuntu 24.04)

Environment

Description

After performing a fresh installation of PostHog using Docker on Ubuntu 24.04, the plugin server is failing to start. The error logs indicate that the encryption keys are not set, causing a startup failure.

Steps to Reproduce

  1. Set up a fresh Ubuntu 24.04 server
  2. Install Docker and Docker Compose
  3. Follow the PostHog self-hosted Docker installation instructions
  4. Attempt to start the PostHog services

Error Logs

{"level":"error","time":1727979202583,"pid":73,"hostname":"f31d1dde2c9f","error":"Error: Encryption keys are not set\n    at new EncryptedFields (/code/plugin-server/dist/cdp/encryption-utils.js:10:19)\n    at createHub (/code/plugin-server/dist/utils/db/hub.js:184:26)\n    at async setupHub (/code/plugin-server/dist/main/pluginsServer.js:157:34)\n    at async startPluginsServer (/code/plugin-server/dist/main/pluginsServer.js:166:25)","msg":"[MAIN] 💥 Launchpad failure!"}
{"level":"error","time":1727979202583,"pid":73,"hostname":"f31d1dde2c9f","error":{},"msg":"[MAIN] 💥 Exception while starting server, shutting down!"}

Expected Behavior

The plugin server should start successfully without any errors.

Actual Behavior

The plugin server fails to start, reporting that encryption keys are not set.

Additional Context

Questions

  1. Are there any additional configuration steps required for setting encryption keys in a self-hosted Docker environment?
  2. Could this be related to any recent changes in PostHog or specific requirements for Ubuntu 24.04?

Any assistance in resolving this issue would be greatly appreciated. Thank you!

Debug info

No response

samuelnygaard commented 3 days ago

I also have this issue

Kvintus commented 3 days ago

Same

Kvintus commented 3 days ago

@switchp0rt @samuelnygaard

So... I found the issue. It's not documented anywhere but we have to set the ENCRYPTION_SALT_KEYS env variable to the compose services, it seems like, anywhere where the SECRET_KEY is provided as well. Most likely just the plugin-server .

The value 00beef0000beef0000beef0000beef00 should be fine. 😊

TLDR: set this env var: ENCRYPTION_SALT_KEYS=00beef0000beef0000beef0000beef00


And to someone from the PostHog team, probably @benjackwhite :

The issue originates here: https://github.com/PostHog/posthog/pull/24966

And although it's stated here, that default value should be provided for hobby deployments:

https://github.com/PostHog/posthog/blob/914ef395c85f31c662188268a39df8d883cf7166/posthog/settings/access.py#L74-L75

The same does not seem to be the case for the plugin-server: https://github.com/PostHog/posthog/blob/914ef395c85f31c662188268a39df8d883cf7166/plugin-server/src/config/config.ts#L178-L180