mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #3774] [bug]: PrismaClientInitializationError: Database #1316
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Avinash0729 on GitHub (Jan 24, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3774
Originally assigned to: @mirarifhasan on GitHub.
Is there an existing issue for this?
Current behavior
When I running backend docker container its throwing an error ,
Backend Server | [Nest] 39 - 01/24/2024, 7:21:07 AM LOG [RouterExplorer] Mapped {/auth/verify/admin, GET} (version: 1) route +1ms
Backend Server | Initialize PubSub
Backend Server | /usr/src/app/node_modules/.pnpm/@prisma+client@4.16.2_prisma@4.16.2/node_modules/@prisma/client/runtime/library.js:108
Backend Server | You may have to run ${S("prisma generate")} for your changes to take effect.
,this.config.clientVersion);return r}parseEngineResponse(r){if(!r)throw new oe("Response from the Engine was empty",{clientVersion:this.config.clientVersion});try{return JSON.parse(r)}catch{throw new oe("Unable to JSON.parse response from engine",{clientVersion:this.config.clientVersion})}}convertDatasources(r){let n=Object.create(null);for(let{name:i,url:o}of r)n[i]=o;return n}async loadEngine(){if(!this.engine){this.QueryEngineConstructor||(this.library=await this.libraryLoader.loadLibrary(),this.QueryEngineConstructor=this.library.QueryEngine);try{let r=new WeakRef(this);this.engine=new this.QueryEngineConstructor({datamodel:this.datamodel,env:process.env,logQueries:this.config.logQueries??!1,ignoreEnvVarErrors:!0,datasourceOverrides:this.datasourceOverrides,logLevel:this.logLevel,configDir:this.config.cwd,engineProtocol:this.engineProtocol},n=>{r.deref()?.logger(n)}),ca++}catch(r){let n=r,i=this.parseInitError(n.message);throw typeof i=="string"?n:new Q(i.message,this.config.clientVersion,i.error_code)}}}logger(r){let n=this.parseEngineResponse(r);if(!!n){if("span"in n){this.config.tracingHelper.createEngineSpan(n);return}n.level=n?.level.toLowerCase()??"unknown",Bp(n)?this.logEmitter.emit("query",{timestamp:new Date,query:n.query,params:n.params,duration:Number(n.duration_ms),target:n.module_path}):Vp(n)?this.loggerRustPanic=new be(this.getErrorMessageWithLink(${n.message}: ${n.reason} in ${n.file}:${n.line}:${n.column}),this.config.clientVersion):this.logEmitter.emit(n.level,{timestamp:new Date,message:n.message,target:n.module_path})}}getErrorMessageWithLink(r){return sa({platform:this.platform,title:r,version:this.config.clientVersion,engineVersion:this.versionInfo?.commit,database:this.config.activeProvider,query:this.lastQuery})}parseInitError(r){try{return JSON.parse(r)}catch{}return r}parseRequestError(r){try{return JSON.parse(r)}catch{}return r}on(r,n){r==="beforeExit"?this.beforeExitListener=n:this.logEmitter.on(r,n)}async start(){if(await this.libraryInstantiationPromise,await this.libraryStoppingPromise,this.libraryStartingPromise)return qe(library already starting, this.libraryStarted: ${this.libraryStarted}),this.libraryStartingPromise;if(this.libraryStarted)return;let r=async()=>{qe("library starting");try{let n={traceparent:this.config.tracingHelper.getTraceParent()};await this.engine?.connect(JSON.stringify(n)),this.libraryStarted=!0,qe("library started")}catch(n){let i=this.parseInitError(n.message);throw typeof i=="string"?n:new Q(i.message,this.config.clientVersion,i.error_code)}finally{this.libraryStartingPromise=void 0}};return this.libraryStartingPromise=this.config.tracingHelper.runInChildSpan("connect",r),this.libraryStartingPromise}async stop(){if(await this.libraryStartingPromise,await this.executingQueryPromise,this.libraryStoppingPromise)return qe("library is already stopping"),this.libraryStoppingPromise;if(!this.libraryStarted)return;let r=async()=>{await new Promise(i=>setTimeout(i,5)),qe("library stopping");let n={traceparent:this.config.tracingHelper.getTraceParent()};await this.engine?.disconnect(JSON.stringify(n)),this.libraryStarted=!1,this.libraryStoppingPromise=void 0,qe("library stopped")};return this.libraryStoppingPromise=this.config.tracingHelper.runInChildSpan("disconnect",r),this.libraryStoppingPromise}async getDmmf(){await this.start();let r=this.config.tracingHelper.getTraceParent(),n=await this.engine.dmmf(JSON.stringify({traceparent:r}));return this.config.tracingHelper.runInChildSpan({name:"parseDmmf",internal:!0},()=>JSON.parse(n))}version(){return this.versionInfo=this.library?.version(),this.versionInfo?.version??"unknown"}debugPanic(r){return this.library?.debugPanic(r)}async request(r,{traceparent:n,interactiveTransaction:i}){qe(sending request, this.libraryStarted: ${this.libraryStarted});let o=JSON.stringify({traceparent:n}),s=JSON.stringify(r);try{await this.start(),this.executingQueryPromise=this.engine?.query(s,o,i?.id),this.lastQuery=s;let a=this.parseEngineResponse(await this.executingQueryPromise);if(a.errors)throw a.errors.length===1?this.buildQueryError(a.errors[0]):new oe(JSON.stringify(a.errors),{clientVersion:this.config.clientVersion});if(this.loggerRustPanic)throw this.loggerRustPanic;return{data:a,elapsed:0}}catch(a){if(a instanceof Q)throw a;if(a.code==="GenericFailure"&&a.message?.startsWith("PANIC:"))throw new be(this.getErrorMessageWithLink(a.message),this.config.clientVersion);let l=this.parseRequestError(a.message);throw typeof l=="string"?a:new oe(${l.message}Backend Server |
Backend Server |
Backend Server | PrismaClientInitializationError: Database
hopscotch_DBdoes not exist on the database server at216.48.179.44:5432.Backend Server | at r (/usr/src/app/node_modules/.pnpm/@prisma+client@4.16.2_prisma@4.16.2/node_modules/@prisma/client/runtime/library.js:108:2574)
Backend Server | at async Proxy.onModuleInit (/usr/src/app/packages/hoppscotch-backend/dist/prisma/prisma.service.js:20:9)
Backend Server | at async Promise.all (index 0)
Backend Server | at async callModuleInitHook (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/hooks/on-module-init.hook.js:43:5)
Backend Server | at async NestApplication.callInitHook (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/nest-application-context.js:223:13)
Backend Server | at async NestApplication.init (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/nest-application.js💯9)
Backend Server | at async NestApplication.listen (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/nest-application.js:169:33)
Backend Server | at async bootstrap (/usr/src/app/packages/hoppscotch-backend/dist/main.js:43:5) {
Backend Server | clientVersion: '4.16.2',
Backend Server | errorCode: 'P1003'
Backend Server | }
Backend Server |
Backend Server | Node.js v18.19.0
Backend Server | ELIFECYCLE Command failed with exit code 1.
Exiting process because Backend Server exited with code 1
if im trying to connect the database its normally connecting and my .env file is
.env
#-----------------------Backend Config------------------------------#
Prisma Config
DATABASE_URL=postgres://hopscotch_DB:hopscotch_DB@216.48.179.44:5432/hopscotch_database # or replace with your database URL
POSTGRES_HOST_AUTH_METHOD=true
ENABLE_SUBPATH_BASED_ACCESS=false
Auth Tokens Config
JWT_SECRET=secretcode123
TOKEN_SALT_COMPLEXITY=10
MAGIC_LINK_TOKEN_VALIDITY=3
REFRESH_TOKEN_VALIDITY=604800000
ACCESS_TOKEN_VALIDITY=86400000
SESSION_SECRET=anothersecretcode123
Hoppscotch App Domain Config
REDIRECT_URL=http://216.48.179.44:3000
WHITELISTED_ORIGINS=http://216.48.179.44:3170,http://216.48.179.44:3000,http://216.48.179.44:3100
VITE_ALLOWED_AUTH_PROVIDERS=GOOGLE,GITHUB,MICROSOFT,EMAIL
Google Auth Config
GOOGLE_CLIENT_ID=*****
GOOGLE_CLIENT_SECRET=*****
GOOGLE_CALLBACK_URL=http://216.48.179.44:3170/v1/auth/google/callback
GOOGLE_SCOPE=email,profile
Github Auth Config
GITHUB_CLIENT_ID=*****
GITHUB_CLIENT_SECRET=****
GITHUB_CALLBACK_URL=http://216.48.179.44:3170/v1/auth/github/callback
GITHUB_SCOPE=user:email
Microsoft Auth Config
MICROSOFT_CLIENT_ID=*****
MICROSOFT_CLIENT_SECRET=*****
MICROSOFT_CALLBACK_URL=http://216.48.179.44:3170/v1/auth/microsoft/callback
MICROSOFT_SCOPE=user.read
MICROSOFT_TENANT=common
Mailer config
MAILER_SMTP_URL=smtps://user@domain.com:pass@smtp.domain.com
MAILER_ADDRESS_FROM=From Name Here" from@example.com
Rate Limit Config
RATE_LIMIT_TTL=60
RATE_LIMIT_MAX=100
#-----------------------Frontend Config------------------------------#
Base URLs
VITE_BASE_URL=http://216.48.179.44:3000
VITE_SHORTCODE_BASE_URL=http://216.48.179.44:3000
VITE_ADMIN_URL=http://216.48.179.44:3000
Backend URLs
VITE_BACKEND_GQL_URL=http://216.48.179.44:3170/graphql
VITE_BACKEND_WS_URL=wss://216.48.179.443170/graphql
VITE_BACKEND_API_URL=http://216.48.179.44:3170/v1
Steps to reproduce
Please Check and help us
Environment
Production
Version
Self-hosted
@mirarifhasan commented on GitHub (Feb 8, 2024):
Hello @Avinash0729
From the error log, it seems backend trying to connect a database which named with
hopscotch_DBBut in your
.envfile, database name mentiondhopscotch_database.I believe there happend some misconfiguration, you just need to cross verify the database URL.