server does not allow insecure connections, client must use SSL/TLS

I have been trying to setup planetscale database with drizzle in my next js application. But I cant seem to form a conneciton with the database and push my generated schema up. When I run the command npx drizzle-kit push:mysql I get this error
const createConnectionErr = new Error();
Error: unknown error: Code: UNAVAILABLE
server does not allow insecure connections, client must use SSL/TLS
const createConnectionErr = new Error();
Error: unknown error: Code: UNAVAILABLE
server does not allow insecure connections, client must use SSL/TLS
this is what my drizzle.config.ts looks like
import { Config } from "drizzle-kit";

import * as dotenv from "dotenv";

dotenv.config({
path: ".env.local",
});

export default {
schema: "./database/schema.ts",
driver: "mysql2",
dbCredentials: {
host: process.env.DATABASE_HOST!,
user: process.env.DATABASE_USERNAME!,
password: process.env.DATABASE_PASSWORD!,
database: "database-name",
},
out: "./drizzle",
} satisfies Config;
import { Config } from "drizzle-kit";

import * as dotenv from "dotenv";

dotenv.config({
path: ".env.local",
});

export default {
schema: "./database/schema.ts",
driver: "mysql2",
dbCredentials: {
host: process.env.DATABASE_HOST!,
user: process.env.DATABASE_USERNAME!,
password: process.env.DATABASE_PASSWORD!,
database: "database-name",
},
out: "./drizzle",
} satisfies Config;
I have also tried using uri instead of host user password and database but that doesn't work either with the ?sslaccept=strict and other variations for it. Tried a bunch of solutions with this but nothing works. Other working repos online have older versions of drizzle-kit and drizzle-orm My versions are
drizzle-kit: v0.20.4
drizzle-orm: v0.29.0
drizzle-kit: v0.20.4
drizzle-orm: v0.29.0
Any help with this? Appericiate you guys looking at this! many thanks
2 Replies
azteca69
azteca6912mo ago
I would recommend using the uri option and add the DATABASE_URL from the generated prisma in Planetscale, you also have to replace the ssl with ?ssl={"rejectUnauthorized":true}
No description
Sphorb
SphorbOP12mo ago
Yeah sadly I tried that but didnt work but eventually just decided to manually add the tables
Want results from more Discord servers?
Add your server