Skip to content

Self-hosted crash with adapter_error_getuserbyemail #1407

@alexey

Description

@alexey

Issue:

When running pure new installation, enter email in the UI, got "Error sending email - try again?"

Error:

docker-compose logs -f cap-web

Attaching to cap-web
cap-web     |    ▲ Next.js 15.5.4
cap-web     |    - Local:        http://localhost:3000
cap-web     |    - Network:      http://0.0.0.0:3000
cap-web     | 
cap-web     |  ✓ Starting...
cap-web     | Waiting 5 seconds to run migrations
cap-web     |  ✓ Ready in 740ms
cap-web     | 🔍 DB migrations triggered
cap-web     | 💿 Running DB migrations...
cap-web     | 💿 Migrations run successfully!
cap-web     | [next-auth][warn][DEBUG_ENABLED] 
cap-web     | https://next-auth.js.org/warnings#debug_enabled
cap-web     | timestamp=2025-11-24T19:17:20.584Z level=INFO fiber=#29 message="Using CAP_AWS_ACCESS_KEY and CAP_AWS_SECRET_KEY"
cap-web     | [next-auth][warn][DEBUG_ENABLED] 
cap-web     | https://next-auth.js.org/warnings#debug_enabled
cap-web     | [next-auth][debug][adapter_getUserByEmail] { args: [ '[email protected]' ] }
cap-web     | [next-auth][error][adapter_error_getUserByEmail] 
cap-web     | https://next-auth.js.org/errors#adapter_error_getuserbyemail Failed query: select `id`, `name`, `lastName`, `email`, `emailVerified`, `image`, `stripeCustomerId`, `stripeSubscriptionId`, `thirdPartyStripeSubscriptionId`, `stripeSubscriptionStatus`, `stripeSubscriptionPriceId`, `preferences`, `activeOrganizationId`, `created_at`, `updated_at`, `onboardingSteps`, `onboarding_completed_at`, `customBucket`, `inviteQuota`, `defaultOrgId` from `users` where `users`.`email` = ? limit ?
cap-web     | params: [email protected],1 {
cap-web     |   message: 'Failed query: select `id`, `name`, `lastName`, `email`, `emailVerified`, `image`, `stripeCustomerId`, `stripeSubscriptionId`, `thirdPartyStripeSubscriptionId`, `stripeSubscriptionStatus`, `stripeSubscriptionPriceId`, `preferences`, `activeOrganizationId`, `created_at`, `updated_at`, `onboardingSteps`, `onboarding_completed_at`, `customBucket`, `inviteQuota`, `defaultOrgId` from `users` where `users`.`email` = ? limit ?\n' +
cap-web     |     'params: [email protected],1',
cap-web     |   stack: 'Error: Failed query: select `id`, `name`, `lastName`, `email`, `emailVerified`, `image`, `stripeCustomerId`, `stripeSubscriptionId`, `thirdPartyStripeSubscriptionId`, `stripeSubscriptionStatus`, `stripeSubscriptionPriceId`, `preferences`, `activeOrganizationId`, `created_at`, `updated_at`, `onboardingSteps`, `onboarding_completed_at`, `customBucket`, `inviteQuota`, `defaultOrgId` from `users` where `users`.`email` = ? limit ?\n' +
cap-web     |     'params: [email protected],1\n' +
cap-web     |     '    at eu.queryWithCache (/app/apps/web/.next/server/chunks/_6c5e8774._.js:12:31523)\n' +
cap-web     |     '    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n' +
cap-web     |     '    at async eu.execute (/app/apps/web/.next/server/chunks/_6c5e8774._.js:12:34362)\n' +
cap-web     |     '    at async getUserByEmail (/app/apps/web/.next/server/chunks/_3de31538._.js:67:3408)',
cap-web     |   name: 'Error'
cap-web     | }
cap-web     | Error [GetUserByEmailError]: Failed query: select `id`, `name`, `lastName`, `email`, `emailVerified`, `image`, `stripeCustomerId`, `stripeSubscriptionId`, `thirdPartyStripeSubscriptionId`, `stripeSubscriptionStatus`, `stripeSubscriptionPriceId`, `preferences`, `activeOrganizationId`, `created_at`, `updated_at`, `onboardingSteps`, `onboarding_completed_at`, `customBucket`, `inviteQuota`, `defaultOrgId` from `users` where `users`.`email` = ? limit ?
cap-web     | params: [email protected],1
cap-web     |     at eu.queryWithCache (.next/server/chunks/_6c5e8774._.js:12:31523)
cap-web     |     at async eu.execute (.next/server/chunks/_6c5e8774._.js:12:34362)
cap-web     |     at async getUserByEmail (.next/server/chunks/_3de31538._.js:67:3408) {
cap-web     |   code: undefined
cap-web     | }

Things tried:

  • Remove all mysql security configs and run root/nopass - same results.

  • RESEND credentials are set(and working with testing with cURL)

  • CAPS_AWS_* are set and the S3 as well

  • docker exec -it ps-mysql mysql -uxxx -pxxx xxx -e "SHOW TABLES;"
    show no tables in the db_name, means no migration ran.

  • I don't have other mysql services on this server.

  • Same outcome with credentials or without.

Interesting that cap-web can run even if db docker is killed, having same error. my concert where it connects for the db or the db connection errors are all are summarized in that error i get ?

Please help

docker-compose.yml:

version: "3.9"

services:
  ps-mysql:
    image: mysql:8.0
    container_name: ps-mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: xxx
      MYSQL_DATABASE: xxx
      MYSQL_USER: xxx
      MYSQL_PASSWORD: xxx
      MYSQL_ROOT_HOST: "%"
    command:
      [
        "--max_connections=1000",
        "--default-authentication-plugin=mysql_native_password",
      ]
    ports:
      - "3306:3306"
    volumes:
      - ./mysql_data:/var/lib/mysql
    networks:
      - cap-net

  cap-web:
    image: ghcr.io/capsoftware/cap-web:latest
    container_name: cap-web
    restart: unless-stopped
    env_file:
      - .env
    expose:
      - "3000"
    networks:
      - cap-net

  nginx:
    image: nginx:alpine
    container_name: cap-nginx
    restart: unless-stopped
    depends_on:
      - cap-web
    ports:
      - "80:80"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d:ro
    networks:
      - cap-net

networks:
  cap-net:
    driver: bridge

.env:

WEB_URL=http://xxx
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=xxx
#NEXTAUTH_URL_INTERNAL=http://localhost:3000

DATABASE_ENCRYPTION_KEY=xxx

MYSQL_ROOT_PASSWORD=xxx
MYSQL_DATABASE=xxx
MYSQL_USER=xxx
MYSQL_PASSWORD=xxx

DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@ps-mysql:3306/${MYSQL_DATABASE}
#DATABASE_URL=mysql://root:CapPass@ps-mysql:3306/db_name?ssl={"rejectUnauthorized":false}

CAP_AWS_ACCESS_KEY=xxx
CAP_AWS_SECRET_KEY=xxx
CAP_AWS_BUCKET=xxx
CAP_AWS_REGION=eu-central
CAP_AWS_ENDPOINT=https://xx.your-objectstorage.com
S3_PUBLIC_ENDPOINT=https://xx.your-objectstorage.com
S3_INTERNAL_ENDPOINT=https://xx.your-objectstorage.com
S3_PATH_STYLE=false

RESEND_API_KEY=xxx
RESEND_FROM_DOMAIN=xxx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions