1 min read

[INTERNAL_SERVER_ERROR] Cannot read properties of undefined (reading 'primary') [Solved]

Have you recently updated Directus and received this message? You have come to the right place.
[INTERNAL_SERVER_ERROR] Cannot read properties of undefined (reading 'primary') [Solved]

Have you recently updated Directus and when you logged in received this message? You have come to the right place.

To resolve this error, you need to run the latest migrations for the database. SSH to your Directus project folder and run npx directus database migrate:latest, then restart Directus.

The full error message appears like the JSON below and basically means it is trying to get data from source that doesn't exist. In this case, the upgrade to Directus required some migrations in the database that hasn't been performed.

{
  "errors": [
    {
      "message": "Cannot read properties of undefined (reading 'primary')",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ]
}

To resolve this issue, you need access to the Directus project folder using Terminal or Command Prompt. Run the following command:

npx directus database migrate:latest

The changes are listed after each step has completed. For example:

INFO: Running migrations...
INFO: Applying Update Material Icons...
INFO: Applying Add Preview Settings...
INFO: Applying Migrate Translation Strings...
INFO: Database up to date

Note the last line tells us the process has complete.

Finally restart Directus to adopt the changes.

For a full guide on how to update Directus, be sure to bookmark the link below:

How to Update Directus?
It’s important to keep Directus up to date. Each new version fixes bugs or issues that have been discovered since the last version and sometimes includes new exciting features.

By continuing to use our website, you consent to use essential cookies. We also use optional tracking cookies which help us gather statistics to improve our services. Do you consent to these cookies?

I Consent Do not track