TypeError [ERR_INVALID_ARG_TYPE]

Viewed 8794

I am trying to run my application server and i keep getting the following error back

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null

am using postgres as my database and below is the content of my db config file

development: {
    database: 'app_dev',
    use_env_variable: 'DATABASE_URL_DEV',
    dialect: 'postgres',
  },
  test: {
    database: 'app_test',
    use_env_variable: 'DATABASE_URL_TEST',
    dialect: 'postgres',
    logging: false,
  }

here am using Sequelize CLI [Node: 12.18.3, CLI: 5.5.1, ORM: 5.21.4]

4 Answers

I had the same problem when running a Node app in Heroku.

This is what fixed it:

development: {
    url: 'DATABASE_URL',
    dialect: 'postgres',
    dialectOptions: {
        ssl: {
            require: true,
            rejectUnauthorized: false
        }
    }
}

I got the same error. It was because I was passing undefined arguments.

Depending on your Postgres initial configuration, you might need to add the following details at your config: username & password.

In my case the wrong env variables implementation + missing keys in config were the reasons of the error:

  1. Check the format of your config/env vars. For example Heroku string vars don't work with additional " "!
  2. Also I had to add username and password keys to sequelize.json in addition to existing use_env_variable: DATABASE_URL.
Related