"User already exists" error when trying to create a user

Why do I get a “User already exists” error when trying to create a user? I can’t see the user in the Users section…


We usually see this on Custom Databases, with import mode either on or off. There are two things to check:

  1. Is the “Get user” script in the Custom DB returning a profile?
    Auth0 executes the “Get User” script before creating the user, to make sure the user doesn’t exist in the external (custom DB). If the script returns a profile (instead of returning null) Auth0 interprets that as “This user already exists” and prevents the creation.
    You can easily test this by hitting the “Test” button when looking at the Get User script for the custom database.

  2. User changed their password but never logged in. This is more of a corner case that can happen if:

    • The user did a complete password reset flow (“Forgot your password?”), but did not log in after that.
    • You are using a Custom DB with Import Mode On.

    When this happens, Auth0 remembers the new password in a “ghost” record, that you don’t see when searching for the user (there’s no full user profile imported to Auth0 yet), but it prevents the user from being created again (because it would result in a different password than the one the user chose). There are two ways to recover from this situation:

    • Have the user log in (with the password they set). If they don’t remember the password, they can do the password reset flow again.
    • Use the Delete user by email endpoint to delete that ghost user from the Auth0 side. Note that if the user was able to do the password reset flow to get to this state, this means that the user already existed in the external database. By doing this deletion you are essentially deleting the new password, so the user will need to use the previous password (in the external DB) to log in.