Unable to connect with Planetscale DB

Hi there,

I am able to connect with Planetscale DB in my local but once deployed it is failing. The error only includes Prisma client ID

"error":{"clientVersion":"4.6.1"}

However, I am thinking it is an issue with SSL connection since am not able to reproduce it in my local and have tried with multiple Prisma clients.

For SSL, I have included command to install CA Certificates in my docker file like mentioned here and also have set MYSQL_ATTR_SSL_CA=''/etc/ssl/certs/ca-certificates.crt" for my app.

My Docker File:

FROM debian:bullseye as builder

ARG NODE_VERSION=18.3.0

RUN apt-get update; apt install -y curl
RUN apt-get update && apt-get install -y openssl && apt-get install -y ca-certificates
RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH /root/.volta/bin:$PATH
RUN volta install node@${NODE_VERSION}

#######################################################################

RUN mkdir /app
WORKDIR /app

COPY . .

RUN npm install && npm run build
FROM debian:bullseye

LABEL fly_launch_runtime="nodejs"

COPY --from=builder /root/.volta /root/.volta
COPY --from=builder /app /app

WORKDIR /app
ENV NODE_ENV production
ENV PATH /root/.volta/bin:$PATH

CMD [ "npm", "run", "start" ]

Hi Kamal, this looks like a known error with the error processing: JSON.stringify loses much of error object information vs using console.log on it · Issue #10141 · prisma/prisma · GitHub

It could be a missing or incorrect configuration, environment variable, or secret. Check that those are all working by fly ssh console into your app, then using the mysql client to connect to the planetscale db. If there are connectively issues, the mysql cli may provide better error messages.

thanks @tvdfly. I was able to solve the issue after going into instance console. The issue was when I was setting the secret with flyctl I had single quotes around the URL. I did it so the command would not break :sob:

After removing the single quotes and setting it like this has resolved the issue for me.
$ flyctl secrets set "DATABASE_URL=<PLANET_SCALE_URL>"

1 Like