Skip to content

Commit facc074

Browse files
romitg2shockzM1Paperclip-Paperclipclaudedevin-ai-integration[bot]
authored
fix(docs): correct self-hosting troubleshooting guide based on codebase verification (calcom#28756)
* docs: add self-hosting troubleshooting guide Add a dedicated troubleshooting page (docs/self-hosting/troubleshooting.mdx) covering the most common self-hosting issues: - 500 error during onboarding caused by missing STRIPE_PRIVATE_KEY (calcom#25993) - Redirect to localhost after deployment (NEXTAUTH_URL / NEXT_PUBLIC_WEBAPP_URL) (calcom#21921) - API v2 service not starting in Docker (missing REDIS_URL, JWT_SECRET, WEB_APP_URL) - CLIENT_FETCH_ERROR in Docker logs - SSL issues behind a reverse proxy - Prisma user creation failure on first setup Also adds the new page to the "Getting Started" navigation group in docs/docs.json. Co-Authored-By: Paperclip <noreply@paperclip.ing> * fix(docs): provide safer SSL troubleshooting alternatives Replace the blanket NODE_TLS_REJECT_UNAUTHORIZED=0 recommendation with three options in order of preference: 1. Use HTTP internally with proper header forwarding 2. Add internal CA to NODE_EXTRA_CA_CERTS 3. Disable TLS verification (last resort with security warning) The previous guidance could expose users to MITM attacks on all external API calls (Stripe, Google, etc.). * fix(docs): correct NEXTAUTH_URL guidance to prevent OAuth breakage The previous guidance recommended setting NEXTAUTH_URL to localhost for SSL/DNS issues, which breaks OAuth callbacks since external providers would redirect to localhost instead of the public domain. - Replace localhost workaround with extra_hosts in docker-compose - Add nginx proxy header configuration example - Add warnings explaining why localhost breaks OAuth Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(docs): correct troubleshooting guide based on codebase verification - Stripe section: Rewrite to accurately reflect current behavior (app gracefully handles missing keys by marking Stripe as 'not installed' rather than crashing). Clarify that NEXT_PUBLIC_STRIPE_PUBLIC_KEY belongs in .env.appStore. - API v2 section: Add missing required vars (STRIPE_API_KEY, STRIPE_WEBHOOK_SECRET, NEXTAUTH_SECRET) that crash the service if absent. Move WEB_APP_URL to optional (it has a fallback default). - CLIENT_FETCH_ERROR section: Add caveat about HTTPS URLs failing with the extra_hosts approach when app listens on port 3000. - Vercel note: Clarify that NEXTAUTH_URL is auto-inferred via VERCEL_URL, not just 'left empty'. - Database section: Replace unverifiable metadata/id advice with actionable migration and setup guidance matching actual code in apps/web/app/api/auth/setup/route.ts. Co-Authored-By: romitgabani1 <romitgabani1.work@gmail.com> * docs: fix inaccuracies in self-hosting troubleshooting guide - Add missing CALENDSO_ENCRYPTION_KEY to API v2 required variables - Fix setup endpoint path from /api/auth/setup to /auth/setup - Add note about NEXTAUTH_URL auto-derivation from NEXT_PUBLIC_WEBAPP_URL * fix(docs): correct NEXTAUTH_URL derivation mechanism description NextAuth infers the base URL from the request's Host header when NEXTAUTH_URL is not set, not from NEXT_PUBLIC_WEBAPP_URL directly. Co-Authored-By: romitgabani1 <romitgabani1.work@gmail.com> --------- Co-authored-by: shockzM1 <shockz@dsn.so> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 25857c0 commit facc074

2 files changed

Lines changed: 220 additions & 1 deletion

File tree

docs/docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129
"self-hosting/upgrading",
130130
"self-hosting/sso-setup",
131131
"self-hosting/docker",
132-
"self-hosting/license-key"
132+
"self-hosting/license-key",
133+
"self-hosting/troubleshooting"
133134
]
134135
},
135136
{
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
---
2+
title: "Troubleshooting"
3+
icon: "triangle-exclamation"
4+
---
5+
6+
This guide covers the most common issues encountered when self-hosting Cal.com, along with their solutions.
7+
8+
## Onboarding / Setup Issues
9+
10+
### Stripe Payment Features Not Working
11+
12+
**Symptom:** Stripe-related features (paid events, app store payment integration) are not available, or you see errors when attempting to use payment features.
13+
14+
**Cause:** The Stripe integration requires several environment variables to be configured. These variables are defined across two files: `.env` (root) and `.env.appStore`. If they are missing or empty, the Stripe app will be marked as "not installed" and payment-related features will be unavailable.
15+
16+
**Solution:** Add the following variables to your `.env` file (root):
17+
18+
```env
19+
STRIPE_PRIVATE_KEY=sk_test_...
20+
STRIPE_CLIENT_ID=ca_...
21+
STRIPE_WEBHOOK_SECRET=whsec_...
22+
```
23+
24+
And in your `.env.appStore` file (or `.env` if using a single file):
25+
26+
```env
27+
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_...
28+
```
29+
30+
> **Note:** Replace these with your actual Stripe API keys from the [Stripe Dashboard](https://dashboard.stripe.com/apikeys). If you don't need payment features, you can safely leave these empty — the app will function without them, but Stripe-related features will be disabled.
31+
32+
Related issue: [#25993](https://github.com/calcom/cal.com/issues/25993)
33+
34+
---
35+
36+
## URL and Redirect Issues
37+
38+
### Redirect to `localhost:3000` After Deployment
39+
40+
**Symptom:** After deploying Cal.com to a server or domain, login redirects or internal links point back to `http://localhost:3000` instead of your actual domain.
41+
42+
**Cause:** The environment variables `NEXTAUTH_URL` and `NEXT_PUBLIC_WEBAPP_URL` are not set to your production domain. These variables tell Cal.com and NextAuth where the app is hosted.
43+
44+
**Solution:** Update your `.env` file to use your actual domain:
45+
46+
```env
47+
# Replace with your actual domain
48+
NEXT_PUBLIC_WEBAPP_URL=https://cal.yourdomain.com
49+
NEXTAUTH_URL=https://cal.yourdomain.com
50+
```
51+
52+
**Important notes:**
53+
- Do **not** include a trailing slash.
54+
- `NEXTAUTH_URL` is optional if `NEXT_PUBLIC_WEBAPP_URL` is set — NextAuth will infer the base URL from the incoming request's `Host` header when `NEXTAUTH_URL` is not explicitly configured.
55+
- For Docker deployments, these must be set **before** building the image, as `NEXT_PUBLIC_WEBAPP_URL` is a build-time variable (it is inlined by Next.js during the build). Rebuild the image after changing it.
56+
- For Vercel deployments, you do **not** need to set `NEXTAUTH_URL` — Vercel automatically infers it from the deployment URL via the `VERCEL_URL` environment variable.
57+
58+
Related issue: [#21921](https://github.com/calcom/cal.com/issues/21921)
59+
60+
---
61+
62+
## Docker-Specific Issues
63+
64+
### API v2 Service Not Starting
65+
66+
**Symptom:** After running `docker compose up -d`, the `calcom-api` service fails to start or immediately exits. The web app works, but API v2 endpoints (`/api/v2/...`) return connection errors.
67+
68+
**Cause:** The API v2 service requires several environment variables that are not in the root `.env.example`. If any required variable is missing, the service will throw a `Missing environment variable` error and exit on startup.
69+
70+
**Solution:** Add the following variables to your root `.env` file (the `docker-compose.yml` passes these to the `calcom-api` service):
71+
72+
```env
73+
# Required for API v2 (service will not start without these)
74+
REDIS_URL=redis://redis:6379
75+
JWT_SECRET=your_random_jwt_secret_here
76+
NEXTAUTH_SECRET=your_nextauth_secret_here
77+
CALENDSO_ENCRYPTION_KEY=your_32_character_encryption_key
78+
STRIPE_API_KEY=sk_test_your_stripe_key
79+
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
80+
81+
# Optional (have sensible defaults)
82+
WEB_APP_URL=https://cal.yourdomain.com
83+
REDIS_PORT=6379
84+
LOG_LEVEL=warn
85+
```
86+
87+
> **Note:** `STRIPE_API_KEY` is the API v2 equivalent of `STRIPE_PRIVATE_KEY` used by the web app. Both are Stripe secret keys but are consumed by different services. If you don't need Stripe functionality in the API, you can set a placeholder value (e.g., `sk_test_placeholder`), but the variable must be present.
88+
89+
You can generate secure secrets with:
90+
91+
```bash
92+
openssl rand -base64 32
93+
```
94+
95+
Then restart the stack:
96+
97+
```bash
98+
docker compose down && docker compose up -d
99+
```
100+
101+
Check the API v2 service logs for further details if it still fails:
102+
103+
```bash
104+
docker compose logs calcom-api
105+
```
106+
107+
> **Tip:** The API v2 service has its own `.env.example` at `apps/api/v2/.env.example` with a complete list of all supported variables. Refer to it for the full configuration reference.
108+
109+
---
110+
111+
### `CLIENT_FETCH_ERROR` in Logs
112+
113+
**Symptom:** The following error appears in Docker logs, and login/session fails:
114+
115+
```
116+
[next-auth][error][CLIENT_FETCH_ERROR]
117+
request to http://<your-domain>/api/auth/session failed, reason: getaddrinfo ENOTFOUND
118+
```
119+
120+
**Cause:** The Docker container cannot resolve the external hostname set in `NEXTAUTH_URL` from within the container's network.
121+
122+
**Solution:** Add your domain to the container's `/etc/hosts` so it resolves to itself:
123+
124+
```yaml
125+
# docker-compose.yml
126+
services:
127+
calcom:
128+
extra_hosts:
129+
- "cal.yourdomain.com:127.0.0.1"
130+
```
131+
132+
This allows the container to resolve your public domain internally while keeping `NEXTAUTH_URL` set to your public URL (required for OAuth callbacks to work).
133+
134+
> **Important:** This approach works when `NEXTAUTH_URL` uses HTTP (e.g., `http://cal.yourdomain.com:3000`). If your `NEXTAUTH_URL` uses HTTPS, the container will attempt to connect to `127.0.0.1:443`, while the app listens on port 3000 — this will fail. In that case, ensure your reverse proxy is also running inside the Docker network, or see the SSL section below.
135+
136+
> **Why not use `localhost`?** Setting `NEXTAUTH_URL` to `localhost` would fix this DNS error, but **breaks OAuth** — external providers like Google would redirect to `localhost` instead of your domain.
137+
138+
---
139+
140+
### SSL / HTTPS Issues Behind a Reverse Proxy
141+
142+
**Symptom:** Requests fail with SSL certificate errors when Cal.com is behind a load balancer or reverse proxy that handles HTTPS termination.
143+
144+
**Solution (choose one):**
145+
146+
**Option 1: If your proxy forwards HTTP internally (most common)**
147+
148+
Keep `NEXTAUTH_URL` set to your **public-facing HTTPS URL**:
149+
150+
```env
151+
NEXTAUTH_URL=https://cal.yourdomain.com
152+
```
153+
154+
Then configure your reverse proxy to forward these headers so internal requests work correctly:
155+
156+
```nginx
157+
# Nginx example
158+
proxy_set_header Host $host;
159+
proxy_set_header X-Forwarded-Proto $scheme;
160+
proxy_set_header X-Forwarded-Host $host;
161+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
162+
```
163+
164+
> **Why not use `localhost`?** Setting `NEXTAUTH_URL=http://localhost:3000` would fix internal SSL errors, but **breaks OAuth callbacks** — external providers (Google, Microsoft) would try to redirect users to `localhost`, which fails. Always use your public URL.
165+
166+
**Option 2: If using self-signed certificates internally**
167+
168+
Add your internal CA to Node's trusted certificates:
169+
170+
```env
171+
NODE_EXTRA_CA_CERTS=/path/to/your-internal-ca.crt
172+
```
173+
174+
**Option 3: Last resort (not recommended for production)**
175+
176+
```env
177+
NODE_TLS_REJECT_UNAUTHORIZED=0
178+
```
179+
180+
> **Security Warning:** This disables **all** TLS certificate verification globally, including external API calls to Stripe, Google Calendar, and other services. This makes your instance vulnerable to man-in-the-middle attacks. Only use this in isolated development environments where you fully control all network traffic.
181+
182+
---
183+
184+
## Database Issues
185+
186+
### First User Setup Fails
187+
188+
**Symptom:** Attempting to create the first admin user via the `/setup` page results in an error.
189+
190+
**Cause:** This can occur if the database migrations have not been applied, or if the database is in an inconsistent state.
191+
192+
**Solution:**
193+
194+
1. Ensure database migrations are applied:
195+
196+
```bash
197+
# For development
198+
yarn workspace @calcom/prisma db-migrate
199+
200+
# For production / Docker
201+
yarn workspace @calcom/prisma db-deploy
202+
```
203+
204+
2. Verify the database is accessible and the `DATABASE_URL` in your `.env` is correct.
205+
206+
3. If the issue persists after migrations, check the application logs for the specific Prisma error message — it will indicate which field or constraint is failing.
207+
208+
> **Note:** The setup endpoint (`/auth/setup`) creates the first user with the `ADMIN` role. It only works when the `User` table is completely empty. If a previous setup attempt partially succeeded, you may need to manually clear the users table before retrying.
209+
210+
---
211+
212+
## Getting Further Help
213+
214+
If your issue is not listed here:
215+
216+
1. Search the [Cal.com GitHub Issues](https://github.com/calcom/cal.com/issues) — many common problems have documented solutions in issue threads.
217+
2. Check the [Cal.com Community](https://community.cal.com) forum.
218+
3. Review the [Docker configuration](./docker) and [Installation guide](./installation) for any steps you may have missed.

0 commit comments

Comments
 (0)