hoppscotch: [bug]: Self host backend container deploy fail and continuous restart when using Mailcatcher

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When setting up the beta self hosted Hoppscotch and running everything using the provided docker images and following the documentation, the hoppscotch-backend container goes into a continual restart loop as it keeps trying configure the mailer using the mailer config I’ve provided in my .env which is a locally hosted MailCatcher url, which is apparently supported according to the docs.

The error logs from the hoppscotch-backend container are below:

> hoppscotch-backend@2023.4.0 start:prod /usr/src/app
> node dist/main

Running in production: true
Port: 3000
Database: postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [NestFactory] Starting Nest application...
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] PubSubModule dependencies initialized +75ms
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] PrismaModule dependencies initialized +1ms
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] MailerModule dependencies initialized +0ms
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] PassportModule dependencies initialized +0ms
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] ThrottlerModule dependencies initialized +1ms
[Nest] 19  - 04/14/2023, 2:46:21 PM     LOG [InstanceLoader] JwtModule dependencies initialized +1ms
[Nest] 19  - 04/14/2023, 2:46:21 PM   ERROR [ExceptionHandler] Cannot create property 'mailer' on string '"smtp://127.0.0.1:1025"'
TypeError: Cannot create property 'mailer' on string '"smtp://127.0.0.1:1025"'
    at new Mail (/usr/src/app/node_modules/.pnpm/nodemailer@6.9.1/node_modules/nodemailer/lib/mailer/index.js:45:33)
    at module.exports.createTransport (/usr/src/app/node_modules/.pnpm/nodemailer@6.9.1/node_modules/nodemailer/lib/nodemailer.js:53:14)
    at MailerTransportFactory.createTransport (/usr/src/app/node_modules/.pnpm/@nestjs-modules+mailer@1.8.1_@nestjs+common@9.2.1_@nestjs+core@9.2.1_nodemailer@6.9.1/node_modules/@nestjs-modules/mailer/dist/mailer-transport.factory.js:13:49)
    at new MailerService (/usr/src/app/node_modules/.pnpm/@nestjs-modules+mailer@1.8.1_@nestjs+common@9.2.1_@nestjs+core@9.2.1_nodemailer@6.9.1/node_modules/@nestjs-modules/mailer/dist/mailer.service.js:38:54)
    at Injector.instantiateClass (/usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/injector/injector.js:340:19)
    at callback (/usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/injector/injector.js:53:45)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Injector.resolveConstructorParams (/usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/injector/injector.js:132:24)
    at async Injector.loadInstance (/usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/injector/injector.js:57:13)
    at async Injector.loadProvider (/usr/src/app/node_modules/.pnpm/@nestjs+core@9.2.1_@nestjs+common@9.2.1_@nestjs+platform-express@9.2.1_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/injector/injector.js:84:9)
 ELIFECYCLE  Command failed with exit code 1.

My .env file is as follows:

#-----------------------Backend Config------------------------------#
# Prisma Config
DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch

# Auth Tokens Config
JWT_SECRET="secret1233"
TOKEN_SALT_COMPLEXITY=10
MAGIC_LINK_TOKEN_VALIDITY= 3
REFRESH_TOKEN_VALIDITY="604800000" # Default validity is 7 days (604800000 ms) in ms
ACCESS_TOKEN_VALIDITY="86400000" # Default validity is 1 day (86400000 ms) in ms
SESSION_SECRET='add some secret here'

# Hoppscotch App Domain Config
REDIRECT_URL="http://localhost:3000"
WHITELISTED_ORIGINS="http://localhost:3170,http://localhost:3000,http://localhost:3100"

# Github Auth Config
GITHUB_CLIENT_ID="redacted"
GITHUB_CLIENT_SECRET=redacted"
GITHUB_CALLBACK_URL="http://localhost:3170/v1/auth/github/callback"
GITHUB_SCOPE="user:email"

# Mailer config
MAILER_SMTP_URL='smtp://127.0.0.1:1025'
MAILER_ADDRESS_FROM='From HoppscotchScope Hoppscotch <hoppscotch@localhostHoppscotch.com>'

# Rate Limit Config
RATE_LIMIT_TTL=60 # In seconds
RATE_LIMIT_MAX=100 # Max requests per IP


#-----------------------Frontend Config------------------------------#


# Base URLs
VITE_BASE_URL=http://localhost:3000
VITE_SHORTCODE_BASE_URL=http://localhost:3000
VITE_ADMIN_URL=http://localhost:3100

# Backend URLs
VITE_BACKEND_GQL_URL=http://localhost:3170/graphql
VITE_BACKEND_WS_URL=wss://localhost:3170/graphql
VITE_BACKEND_API_URL=http://localhost:3170/v1

# Terms Of Service And Privacy Policy Links (Optional)
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/terms
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/privacy

Steps to reproduce

  1. Follow the docs to install the requirements for your self hosted hoppscotch beta
  2. Set up MailCatcher on your local machine
  3. Test that MailCatcher works using a simple Python (or other) script
  4. Populate your .env file in the root directory of the project folder - include MailCatcher smpt url in it

MAILER_SMTP_URL=‘smtp://127.0.0.1:1025’

  1. Follow the rest of the docs to configure, build and run the relevant docker containers
  2. Run docker ps and note the container ID of the ‘hoppscotch_hoppscotch-backend’ container
  3. Container Status will be “Restarting”
  4. Run ‘docker logs id’ to get logs and you will see the error I provided above

Environment

Production

Version

Self-hosted

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

I highly suggest creating a new thread for new issues.

1: Now I still have can’t login because I’m having issues with the login with email, I get “Network Error” red pop up alert at the bottom of the screen.

What’s the output of your browser console and network tracing when clicking “Login”?

I’m having a similar issue with CORS rejecting http://localhost:3170/v1/auth/signin and initially on load im getting http://localhost:3170/graphql being rejected

Created a new issue here: https://github.com/hoppscotch/hoppscotch/issues/3009

We use Mailcatcher internally to debug our mailer so we are pretty sure this should work. 😅

Can you post the .env file (just the MAILER bits would be fine).