0

The error after clicking signup button (the minified code is so long so I left out unimportant part)

2025-07-31T13:14:19.733Z ERROR [Better Auth]: Failed to create user Error [PrismaClientValidationError]: 
Invalid `prisma.user.create()` invocation:

{
  data: {
    name: "Test",
    email: "[email protected]",
    emailVerified: false,
                   ~~~~~
    createdAt: new Date("2025-07-31T13:14:19.530Z"),
    updatedAt: new Date("2025-07-31T13:14:19.530Z"),
    id: "7H8P4GQBkSr8jbOuuCN6z2pdp1jR0SPM"
  },
  select: undefined
}

Argument `emailVerified`: Invalid value provided. Expected DateTime or Null, provided Boolean.
    at Dn (lib\generated\prisma\runtime\library.js:32:1362)
    at ri.handleRequestError (lib\generated\prisma\runtime\library.js:124:7101)
    at ri.handleAndLogRequestError (lib\generated\prisma\runtime\library.js:124:6783)
    at ri.request (lib\generated\prisma\runtime\library.js:124:6490)
    at async l (lib\generated\prisma\runtime\library.js:133:9811)
 
........ 
........
......
.....
.....

j(e,{clientVersion:t,batchRequestIdx:r.batch_request_idx})}function mm(e,r){let t=e.message;return(r==="postgresql"||r==="postgres"||r==="mysql")&&e.error_code===dm&&(t+=`
     |

        ^
  33 | Prisma Accelerate has built-in connection pooling to prevent such errors: https://pris.ly/client/error-accelerate`),t}var vt="<unknown>";function qa(e){var r=e.split(`
({model:s.modelName,operation:s.action,args:s.args})),transaction:o?{isolationLevel:o.kind==="batch"?o.isolationLevel:void 0}:void 0},__internalParams:e,query(s,a=e){let l=a.customDataProxyFetch;return a.customDataProxyFetch=al(i,l),sl(a,r,t+1,n)}})}var tl=e=>e;function al(e=tl,r=tl){return t=>e(r(t))}var ll=N("prisma:client"),ul={Vercel:"vercel","Netlify CI":"netlify"};function cl({postinstall:e,ciName:r,clientVersion:t}){if(ll("checkPlatformCaching:postinstall",e),ll("checkPlatformCaching:ciName",r),e===!0&&r&&r in ul){let n=`Prisma has detected that this project was built on ${r}, which caches dependencies. This leads to an outdated Prisma Client because Prisma's auto-generation isn't triggered. To fix this, make sure to run the \`prisma generate\` command during 
the build process.
  35 | {
  clientVersion: '6.13.0'
}
 POST /api/auth/sign-up/email 422 in 8069ms

  • I am using neon(free plan): i created project and selected prisma to connect and use the prisma env my .env file:DATABASE_URL="postgresql://neondb_owner:npg_*******@ep-steep-cell-aewokbc9-pooler.c-2.us-east-2.aws.neon.tech/neondb?sslmode=require&channel_binding=require"

I regenerated Prisma client, did db push, generate, pull, restarted dev server, deleted generated prisma and regenerate again, made sure .env is loaded, and still no luck.

i made sure the problem is not in my schema.prisma or my better-auth usage to sign-up users. My signup page

"use client";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import Link from "next/link";
import { authClient } from "@/lib/auth-client";
import { useState } from "react";
import { toast } from "sonner";

export function SignupForm({
  className,
  ...props
}: React.ComponentProps<"form">) {
  const [name, setName] = useState("");
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const [loading, setLoading] = useState(false);
  const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    if (name.length < 2 || password.length < 8) {
      toast.error("Invalid name or password or email. Please try again.");
      return;
    }

    const { data, error } = await authClient.signUp.email(
      {
        email,
        name,
        password,
        callbackURL: "/dashboard",
      },
      {
        onRequest: () => {
          setLoading(true);
        },
        onSuccess: async () => {
          setLoading(false);
          toast.success(
            "Account created successfully! Please check your email to verify your account."
          );
          await authClient.sendVerificationEmail({
            email,
            callbackURL: "/dashboard",
          });
        },
        onError: (ctx) => {
          toast.error(ctx.error.message);
          console.log(ctx.error);
          setLoading(false);
        },
      }
    );
  };
  return (
    <form
      className={cn("flex flex-col gap-6", className)}
      {...props}
      onSubmit={handleSubmit}
    >
      <div className="flex flex-col items-center gap-2 text-center">
        <h1 className="text-2xl font-bold">Create an account</h1>
        <p className="text-muted-foreground text-sm text-balance">
          Signup to access all features of Smart Grader
        </p>
      </div>
      <div className="grid gap-6">
        <div className="grid gap-3">
          <Label htmlFor="name">Name</Label>
          <Input
            id="name"
            type="text"
            placeholder="name"
            value={name}
            onChange={(e) => setName(e.target.value)}
            required
          />
        </div>
        <div className="grid gap-3">
          <Label htmlFor="email">Email</Label>
          <Input
            id="email"
            type="email"
            placeholder="[email protected]"
            required
            value={email}
            onChange={(e) => setEmail(e.target.value)}
          />
        </div>
        <div className="grid gap-3">
          <div className="flex items-center">
            <Label htmlFor="password">Password</Label>
          </div>
          <Input
            id="password"
            type="password"
            placeholder="password..."
            value={password}
            onChange={(e) => setPassword(e.target.value)}
            required
          />
        </div>
        <Button type="submit" className="w-full" disabled={loading}>
          {loading ? "Creating account..." : "Sign up"}
        </Button>
        <div className="after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t">
          <span className="bg-background text-muted-foreground relative z-10 px-2">
            Or continue with
          </span>
        </div>
        <Button variant="outline" className="w-full">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path
              d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
              fill="currentColor"
            />
          </svg>
          continue with GitHub
        </Button>
      </div>
      <div className="text-center text-sm">
        Already have an account?{" "}
        <Link href="/login" className="underline underline-offset-4">
          Login
        </Link>
      </div>
    </form>
  );
}

most of the time when i pnpm dlx prisma db push i get this error too

>pnpm dlx prisma db push
Packages: +53
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 53, reused 53, downloaded 0, added 53, done
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "Smart%20Grader", schema "public" at "ep-steep-cell-aewokbc9-pooler.c-2.us-east-2.aws.neon.tech"

Error: P1001: Can't reach database server at `ep-steep-cell-aewokbc9-pooler.c-2.us-east-2.aws.neon.tech:5432`        

Please make sure your database server is running at `ep-steep-cell-aewokbc9-pooler.c-2.us-east-2.aws.neon.tech:5432`.

What am i actually missing? please help

1 Answer 1

0

Looks like there are 2 issue.

a. first main issue is, your prisma orm can not connect to database.
your terminal says this

Error: P1001: Can't reach database server at `ep-steep-cell-aewokbc9-pooler.c-2.us-east-2.aws.neon.tech:5432`

so first make sure, your database can be connected via prisma orm

b. second issue is, your User model emailVerified column support either DateTime or Null data type. but you are provding false which is mistaken data type

You need to fix these two issue first.

Sign up to request clarification or add additional context in comments.

2 Comments

The emailVerified field mistake was on meI mistakenly passed boolean instead of DateTime.But the Failed to create user Error [PrismaClientValidationError]: Invalid prisma.user.create()` invocation` error still happens. sth si wrong with my neon connection ig
yes, i mentioned earlier. the first issue is prisma can not connect to database. double check database url from neon & on your source code. wait a minute. are you using prisma .config.tsfile? your app is in docker? if possible, maybe share your github repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.