Hi all, Is it possible to self host <cal.com> on ...
# developers
s
Hi all, Is it possible to self host cal.com on something other than localhost? When I try to change the NEXT_* URLS I still end up with issues. After running "Yarn dx" I get this message 'ready - started server on 0.0.0.0:3000, url: http://localhost:3000' which indicates that some variable is not being set with the proper URL. Furthermore, when I try to interact with the app I get an ECONNREFUSED error. Thanks in advance
a
Hey Samuel, you might be missing NEXTAUTH_URL? If you can post the full error message, that would help us know what’s up
s
Hey @Agusti, Sorry that question was pretty vague. Here's a bit more detail. Currently my .env is configured as follows (with domain replaced with my actual domain). I don't believe I'm missing the NEXTAUTH_URL but I could be misconfiguring it.
Copy code
# ********** INDEX **********
#
# - LICENSE
# - DATABASE
# - SHARED
#   - NEXTAUTH
# - E-MAIL SETTINGS

# - LICENSE *************************************************************************************************
# Set this value to 'agree' to accept our license:
# LICENSE: <https://github.com/calendso/calendso/blob/main/LICENSE>
#
# Summary of terms:
# - The codebase has to stay open source, whether it was modified or not
# - You can not repackage or sell the codebase
# - Acquire a commercial license to remove these terms by visiting: <http://cal.com/sales|cal.com/sales>
NEXT_PUBLIC_LICENSE_CONSENT='agree'
# To enable enterprise-only features, fill your license key in here.
# @see <https://console.cal.com>
CALCOM_LICENSE_KEY=
# ***********************************************************************************************************

# - DATABASE ************************************************************************************************
# :warning: :warning: :warning: DATABASE_URL got moved to `packages/prisma/.env.example` :warning: :warning: :warning:
# ***********************************************************************************************************

# - SHARED **************************************************************************************************
NEXT_PUBLIC_WEBAPP_URL='<https://cal-dev.domain.com>'
# Change to '<http://localhost:3001>' if running the website simultaneously
NEXT_PUBLIC_WEBSITE_URL='<https://cal-dev.domain.com>'
NEXT_PUBLIC_CONSOLE_URL='<https://cal-dev.domain.com>'
NEXT_PUBLIC_EMBED_LIB_URL='<https://cal-dev.domain.com>'

# To enable SAML login, set both these variables
# @see <https://github.com/calcom/cal.com/tree/main/packages/ee#setting-up-saml-login>
# SAML_DATABASE_URL="<postgresql://postgres>:@localhost:5450/cal-saml"
SAML_DATABASE_URL=
# SAML_ADMINS='<mailto:pro@example.com|pro@example.com>'
SAML_ADMINS=
# If you use Heroku to deploy Postgres (or use self-signed certs for Postgres) then uncomment the follow line.
# @see <https://devcenter.heroku.com/articles/connecting-heroku-postgres#connecting-in-node-js>
#PGSSLMODE='no-verify'
PGSSLMODE=

#   - NEXTAUTH
# @see: <https://github.com/calendso/calendso/issues/263>
# @see: <https://next-auth.js.org/configuration/options#nextauth_url>
# Required for Vercel hosting - set NEXTAUTH_URL to equal your NEXT_PUBLIC_WEBAPP_URL
# NEXTAUTH_URL='<http://localhost:3000>'
NEXTAUTH_URL='<https://cal-dev.domain.com>'
# @see: <https://next-auth.js.org/configuration/options#nextauth_secret>
# You can use: `openssl rand -base64 32` to generate one
NEXTAUTH_SECRET='8iglAATVcaYole9M72Rk1AgXEvMK6P1TIJ6Ry+TIWmo='
# Used for cross-domain cookie authentication
NEXTAUTH_COOKIE_DOMAIN=.<http://domain.com|domain.com>

# Set this to '1' if you don't want Cal to collect anonymous usage
CALCOM_TELEMETRY_DISABLED=

# ApiKey for cronjobs
CRON_API_KEY='0cc0e6c35519bba620c9360cfe3e68d0'

# Application Key for symmetric encryption and decryption
# must be 32 bytes for AES256 encryption algorithm
# You can use: `openssl rand -base64 24` to generate one
CALENDSO_ENCRYPTION_KEY='Yl105MjDtx1ehwMvqkSQnNRHEaDyzyZp'

# Intercom Config
NEXT_PUBLIC_INTERCOM_APP_ID=

# Zendesk Config
NEXT_PUBLIC_ZENDESK_KEY=

# Help Scout Config
NEXT_PUBLIC_HELPSCOUT_KEY=

# Inbox to send user feedback
SEND_FEEDBACK_EMAIL=

# This is used so we can bypass emails in auth flows for E2E testing
# Set it to "1" if you need to run E2E tests locally
NEXT_PUBLIC_IS_E2E=

# Used for internal billing system
NEXT_PUBLIC_STRIPE_PRO_PLAN_PRODUCT=
NEXT_PUBLIC_STRIPE_PRO_PLAN_PRICE=
NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE=
NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE=

# Use for internal Public API Keys and optional
API_KEY_PREFIX=cal_
# ***********************************************************************************************************

# - E-MAIL SETTINGS *****************************************************************************************
# Cal uses nodemailer (@see <https://nodemailer.com/about/>) to provide email sending. As such we are trying to
# allow access to the nodemailer transports from the .env file. E-mail templates are accessible within lib/emails/
# Configures the global From: header whilst sending emails.
EMAIL_FROM='<mailto:notifications@yourselfhostedcal.com|notifications@yourselfhostedcal.com>'

# Configure SMTP settings (@see <https://nodemailer.com/smtp/>).
# Note: The below configuration for Office 365 has been verified to work.
EMAIL_SERVER_HOST='<http://smtp.office365.com|smtp.office365.com>'
EMAIL_SERVER_PORT=587
EMAIL_SERVER_USER='<office365_emailAddress>'
# Keep in mind that if you have 2FA enabled, you will need to provision an App Password.
EMAIL_SERVER_PASSWORD='<office365_password>'

# The following configuration for Gmail has been verified to work.
# EMAIL_SERVER_HOST='<http://smtp.gmail.com|smtp.gmail.com>'
# EMAIL_SERVER_PORT=465
# EMAIL_SERVER_USER='<gmail_emailAddress>'
## You will need to provision an App Password.
## @see <https://support.google.com/accounts/answer/185833>
# EMAIL_SERVER_PASSWORD='<gmail_app_password>'
# **********************************************************************************************************
And when I run yarn build > yarn start I get the following:
Copy code
@calcom/prisma:db-deploy: cache bypass, force executing 99465f34e8ed5305
@calcom/prisma:db-deploy: $ yarn prisma migrate deploy
@calcom/prisma:db-deploy: $ /home/ubuntu/cal.com/node_modules/.bin/prisma migrate deploy
@calcom/prisma:db-deploy: Environment variables loaded from .env
@calcom/prisma:db-deploy: Prisma schema loaded from schema.prisma
@calcom/prisma:db-deploy: Datasource "db": PostgreSQL database "calendso", schema "public" at "localhost:5450"
@calcom/prisma:db-deploy: 
@calcom/prisma:db-deploy: 101 migrations found in prisma/migrations
@calcom/prisma:db-deploy: 
@calcom/prisma:db-deploy: 
@calcom/prisma:db-deploy: No pending migrations to apply.
@calcom/prisma:db-deploy: ┌─────────────────────────────────────────────────────────┐
@calcom/prisma:db-deploy: │  Update available 3.14.0 -> 3.15.0                      │
@calcom/prisma:db-deploy: │  Run the following to update                            │
@calcom/prisma:db-deploy: │    yarn add --dev prisma@latest                         │
@calcom/prisma:db-deploy: │    yarn add @prisma/client@latest                       │
@calcom/prisma:db-deploy: └─────────────────────────────────────────────────────────┘
@calcom/web:start: cache miss, executing d5d92574c190ab7e
@calcom/web:start: $ next start
@calcom/web:start: ready - started server on 0.0.0.0:3000, url: <http://localhost:3000>
@calcom/web:start: warn  - using beta Middleware (not covered by semver) - <https://nextjs.org/docs/messages/beta-middleware>
@calcom/web:start: [next-auth][error][CLIENT_FETCH_ERROR] 
@calcom/web:start: <https://next-auth.js.org/errors#client_fetch_error> request to <https://cal-dev.domain.com/api/auth/session> failed, reason: connect ECONNREFUSED 127.0.0.1:443 {
@calcom/web:start:   error: {
@calcom/web:start:     message: 'request to <https://cal-dev.domain.com/api/auth/session> failed, reason: connect ECONNREFUSED 127.0.0.1:443',
@calcom/web:start:     stack: 'FetchError: request to <https://cal-dev.domain.com/api/auth/session> failed, reason: connect ECONNREFUSED 127.0.0.1:443\n' +
@calcom/web:start:       '    at ClientRequest.<anonymous> (/home/ubuntu/cal.com/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)\n' +
@calcom/web:start:       '    at ClientRequest.emit (events.js:400:28)\n' +
@calcom/web:start:       '    at TLSSocket.socketErrorListener (_http_client.js:475:9)\n' +
@calcom/web:start:       '    at TLSSocket.emit (events.js:400:28)\n' +
@calcom/web:start:       '    at emitErrorNT (internal/streams/destroy.js:106:8)\n' +
@calcom/web:start:       '    at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' +
@calcom/web:start:       '    at processTicksAndRejections (internal/process/task_queues.js:82:21)',
@calcom/web:start:     name: 'FetchError'
@calcom/web:start:   },
@calcom/web:start:   path: 'session',
@calcom/web:start:   header: {
@calcom/web:start:     host: '10.100.251.38:3000',
@calcom/web:start:     connection: 'close',
@calcom/web:start:     'user-agent': 'ELB-HealthChecker/2.0',
@calcom/web:start:     'accept-encoding': 'gzip, compressed'
@calcom/web:start:   },
@calcom/web:start:   message: 'request to <https://cal-dev.domain.com/api/auth/session> failed, reason: connect ECONNREFUSED 127.0.0.1:443'
@calcom/web:start: }
I am running this on a ubuntu ec2 instance that is behind an AWS application load balancer. The load balancer is configured to route traffic to the host with https as the protocol
I should add that the home page loads, but this error also shows up when I attempt to login with one of the test accounts:
Copy code
@calcom/web:start: [next-auth][error][CLIENT_FETCH_ERROR] 
@calcom/web:start: <https://next-auth.js.org/errors#client_fetch_error> request to <https://cal-dev.domain.com/api/auth/csrf> failed, reason: connect ECONNREFUSED 127.0.0.1:443 {
@calcom/web:start:   error: {
@calcom/web:start:     message: 'request to <https://cal-dev.domain.com/api/auth/csrf> failed, reason: connect ECONNREFUSED 127.0.0.1:443',
@calcom/web:start:     stack: 'FetchError: request to <https://cal-dev.domain.com/api/auth/csrf> failed, reason: connect ECONNREFUSED 127.0.0.1:443\n' +
@calcom/web:start:       '    at ClientRequest.<anonymous> (/home/ubuntu/cal.com/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)\n' +
@calcom/web:start:       '    at ClientRequest.emit (events.js:400:28)\n' +
@calcom/web:start:       '    at TLSSocket.socketErrorListener (_http_client.js:475:9)\n' +
@calcom/web:start:       '    at TLSSocket.emit (events.js:400:28)\n' +
@calcom/web:start:       '    at emitErrorNT (internal/streams/destroy.js:106:8)\n' +
@calcom/web:start:       '    at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' +
@calcom/web:start:       '    at processTicksAndRejections (internal/process/task_queues.js:82:21)',
@calcom/web:start:     name: 'FetchError'
@calcom/web:start:   },
@calcom/web:start:   path: 'csrf',
@calcom/web:start:   header: {
@calcom/web:start:     'x-forwarded-for': '10.171.98.11',
@calcom/web:start:     'x-forwarded-proto': 'https',
@calcom/web:start:     'x-forwarded-port': '443',
@calcom/web:start:     host: '<http://cal-dev.domain.com|cal-dev.domain.com>',
@calcom/web:start:     'x-amzn-trace-id': 'Root=1-62a0c2da-068660f11d2c72b302d98bfd',
@calcom/web:start:     'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"',
@calcom/web:start:     'sec-ch-ua-mobile': '?0',
@calcom/web:start:     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36',
@calcom/web:start:     'sec-ch-ua-platform': '"macOS"',
@calcom/web:start:     accept: '*/*',
@calcom/web:start:     'sec-fetch-site': 'same-origin',
@calcom/web:start:     'sec-fetch-mode': 'cors',
@calcom/web:start:     'sec-fetch-dest': 'empty',
@calcom/web:start:     referer: '<https://cal-dev.domain.com/auth/login>',
@calcom/web:start:     'accept-encoding': 'gzip, deflate, br',
@calcom/web:start:     'accept-language': 'en-US,en;q=0.9',
@calcom/web:start:     cookie: 'rl_user_id=%22%22; _y=cdfa46ea-2eb8-4894-9ec5-08269c73ba72; _shopify_y=cdfa46ea-2eb8-4894-9ec5-08269c73ba72; _tracking_consent=%7B%22reg%22%3A%22%22%2C%22v%22%3A%222.0%22%2C%22con%22%3A%7B%22CCPA%22%3A%22%22%7D%2C%22lim%22%3A%5B%22CCPA%22%5D%7D; _ga=GA1.2.716419919.1637103580; ajs_user_id=%22897e740ca0e88d642fed687160cd1be4f04371f0%22; ajs_anonymous_id=%221eab192c-8134-4c28-a15b-c3a1a8fc8fd4%22; logged_out_marketing_header_id=eyJfcmFpbHMiOnsibWVzc2FnZSI6IklqSTFZall3WkRReExUbGlNV0V0TkRWa1lpMWhabUU1TFdaa05UUmxOekV3Tm1Jd09TST0iLCJleHAiOm51bGwsInB1ciI6ImNvb2tpZS5sb2dnZWRfb3V0X21hcmtldGluZ19oZWFkZXJfaWQifX0%3D--afb2644b660bce33f1bfa9fe9ab7d2c325e6d03a; mp_da81ae714798a5fc29a48c0d6d4b4f61_mixpanel=%7B%22distinct_id%22%3A%20%2217fe71c2f66841-0f3bfcdd6c5f17-1c3a645d-384000-17fe71c2f67af6%22%2C%22%24device_id%22%3A%20%2217fe71c2f66841-0f3bfcdd6c5f17-1c3a645d-384000-17fe71c2f67af6%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; _gcl_au=1.1.49028290.1652901608; next-auth.csrf-token=e3bd92dfb609a0e6f1114ff8441d0aee7c64375915ceb5937f09156747180dcd%7C5534eefc4da648b3147ba612f948de23ad9d19a36b0395beda5cff60e0f44d7a; __clnds=lm04ejgr4v; next-auth.callback-url=http%3A%2F%2F10.100.251.38%3A3000%2F; next-auth.session-token=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..3ncEFmx_ytuVj-iE.xL_rDzHQkIdlLZM2s6Ap1vBlMHf_E2f2f2gMhW5Klvj0tvy2b1VVXvKM2Orw_olPjaQ9s9QpyXjsi4R1vlRZHlzyXj__i0FBzi8t8CT3T4UZgZUbt01Q-GHc7rzZ22GGASSFk9tW9si8uxwRO-wBBmjsm4Y4_bdcdxbOiONZ9DYljP5CPJxb3Qbg3edDRIuYj4LXo0DZR5i-hA.2QezgMXDWgGWicQL7Dg78Q; __Secure-next-auth.callback-url=https%3A%2F%2Fcal-dev.domain.com%3A3000%2F; __Secure-next-auth.csrf-token=bf99c676e2f53e36232b6c86c714bb3c67f38812649506ac9f087e7889ade7c8%7Cc46466bc276235a500cc16356d31898dac6db53438199c83c3667bf98e23bbe4; AWSALB=8UEvymmHaMTKYYIxs58CMv1ZQfUgET74LBcmZaxSqplreL6f7zU9zr6wReCA8Kjh2SYuT/MdDX1f6D6sh8f9NoC4FCg2Xj+4lAy6ti6X9akyWZkdY7KZ3B3prJgy; AWSALBCORS=8UEvymmHaMTKYYIxs58CMv1ZQfUgET74LBcmZaxSqplreL6f7zU9zr6wReCA8Kjh2SYuT/MdDX1f6D6sh8f9NoC4FCg2Xj+4lAy6ti6X9akyWZkdY7KZ3B3prJgy; __Secure-next-auth.callback-url=<http://https%3A%2F%2Fcal-dev.domain.com|https%3A%2F%2Fcal-dev.domain.com>; __Secure-next-auth.session-token=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..VTlhha8x_Gn4g9U0.-96vDG6pQDAxbCEuTOA8bMfMxxEwS42DFi_H1jsCWBUmjTzI-uXTevAtymTvvI-sesWuDIca93TEWCAtPJfRAA7KUQEmiK2hLWgJ3-o6fz9KxdKBgeLgKfxv4-G_Gp2RzIueW2YaMTXfTqrPoVhWp4XIlLJ4SqS-9SPFxam3DoAWMnLa2Yq-BS0bQ8B5HvYDVdiQTGn-vB9JlkFRuCgubzk2kinW.5EvzB1eaRIowHkCyB2kKSA'