convex-backend icon indicating copy to clipboard operation
convex-backend copied to clipboard

Unable to use admin key using self hosted docker compose

Open ctrlShiftBryan opened this issue 4 months ago • 8 comments

I'm trying to follow the guide here.

https://github.com/get-convex/convex-backend/tree/main/self-hosted

➜  self-convex git:(main) ✗ curl -O https://raw.githubusercontent.com/get-convex/convex-backend/main/self-hosted/docker/docker-compose.yml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2111  100  2111    0     0  10370      0 --:--:-- --:--:-- --:--:-- 10399
➜  self-convex git:(main) ✗ docker compose up -d
[+] Running 3/3
 ✔ Network self-convex_default        Created                                                                                                                                                                                                                                                                                                                          0.0s
 ✔ Container self-convex-backend-1    Healthy                                                                                                                                                                                                                                                                                                                          5.6s
 ✔ Container self-convex-dashboard-1  Started                                                                                                                                                                                                                                                                                                                          5.7s
➜  self-convex git:(main) ✗ docker compose exec backend ./generate_admin_key.sh
Admin key:
convex-self-hosted|016aecfef07a512ed12e84a21075e2d1c73ed88476c2ea5f55d7fb41899309686fafb88706
➜  self-convex git:(main) ✗ curl 'http://127.0.0.1:3210/api/check_admin_key' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Authorization: Convex convex-self-hosted|016aecfef07a512ed12e84a21075e2d1c73ed88476c2ea5f55d7fb41899309686fafb88706' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Convex-Client: dashboard-0.0.0' \
  -H 'DNT: 1' \
  -H 'Origin: http://localhost:6791' \
  -H 'Referer: http://localhost:6791/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: cross-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-gpc: 1'
{"code":"BadAdminKey","message":"The provided admin key was invalid for this instance"}%

same thing in the UI:

Image

I've also attempted with 'npx convex dev' and get this same error

➜  self-convex git:(main) ✗ c .env.local
➜  self-convex git:(main) ✗ npm install convex@latest

added 5 packages in 3s

1 package is looking for funding
  run `npm fund` for details
➜  self-convex git:(main) ✗ npx convex dev

Saved the given --url as CONVEX_URL to .env.local
✖ Error: Unable to pull deployment config from http://127.0.0.1:3210
✖ Error fetching POST  http://127.0.0.1:3210/api/get_config_hashes 401 Unauthorized: BadAdminKey: The provided admin key was invalid for this instance
Authenticate with `npx convex dev`

ctrlShiftBryan avatar Aug 03 '25 14:08 ctrlShiftBryan

Update: tried the exact same steps on a different laptop and didn't have any issues.

This doesn't make sense? everything is in docker and should be isolated from the host? how does the docker host environment impact this?

ctrlShiftBryan avatar Aug 03 '25 14:08 ctrlShiftBryan

Could the version of docker impact this?

Broken in Docker version 28.3.0, build 38b7060

Works in Docker version 20.10.11, build dea9396

ctrlShiftBryan avatar Aug 03 '25 14:08 ctrlShiftBryan

do you possibly have more than one docker image running? That error arises if the admin key is from one deployment but being used on another one.

I doubt docker version is relevant, but you could narrow it down by trying both docker versions on a single laptop.

I am unable to repro - things are working when I try.

nipunn1313 avatar Aug 04 '25 21:08 nipunn1313

any update?

axelcasauran avatar Sep 21 '25 21:09 axelcasauran

I got the same issue , running on dokploy i got the same error even though the key was generated from the terminal and used on the instance , and the log also says invalid admin key

viperxeyes avatar Oct 16 '25 18:10 viperxeyes

Do you have the port authority extension on your browser. When i disabled it, it worked perfectly.

wbrous avatar Oct 18 '25 00:10 wbrous

Did you find any solution ? Using dokploy template and I have thé same issue

jdavidremm avatar Nov 16 '25 19:11 jdavidremm

Can the admin key be overwritten using env variables instead of having to execute a command? 👀

kno-raziel avatar Nov 24 '25 22:11 kno-raziel

The issue with dokploy seems to be related to changing the domains which only become active after a rebuild/reload

evanrooijen avatar Nov 29 '25 12:11 evanrooijen

Can the admin key be overwritten using env variables instead of having to execute a command? 👀

I have been playing more with the self hosted version..., and it seems if the INSTANCE_NAME & INSTANCE_SECRET are set and using the same values across multiple deployments, user can reuse previous admin key.

Even thought it would be nice to have the option to directly set the adming key from env variables. 😬

kno-raziel avatar Dec 06 '25 18:12 kno-raziel