Postgresql Node.js Express Sequelize ERROR - parameter url must be string





Im using pgsql node exprss and trying to use sequelize to db:migrate

but I keep running into this error

I don’t understand what url is it refering to.

Let me know if anyone has a solution


Sequelize CLI [Node: 8.9.1, CLI: 3.1.0, ORM: 1.7.5]

Loaded configuration file “config/config.json”.
Using environment “development”.

ERROR: TypeError: Parameter “url” must be a string, not object
at Url.parse (url.js:103:11)
at Object.urlParse [as parse] (url.js:97:13)
at new Sequelize (/mnt/shared/lib/node_modules/sequelize/lib/sequelize.js:59:22)
at getSequelizeInstance (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/lib/core/migrator.js:49:12)
at /home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/lib/core/migrator.js:62:21
at tryCatcher (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/method.js:39:29)
at getMigrator (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/lib/core/migrator.js:56:32)
at migrate (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/lib/commands/migrate.js:56:36)
at Object. (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/lib/commands/migrate.js:37:15)
at ()
at Generator.tryCatcher (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/generators.js:97:49)
at Promise._settlePromise (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/ubuntu/.nvm/versions/node/v8.9.1/lib/node_modules/sequelize-cli/node_modules/bluebird/js/release/promise.js:693:18)


I’ve been getting the same error. Have you managed to resolve this?


nope :/

i tired the same code on my local pc
and on heroku

both works

just not on c9


Can I assume we were all following the same tutorial… ?

NodeJS Blue prints, issue with sequelize on Cloud 9

I’ve been following the tutorial in chapter 2 of NodeJS Blue Prints
NodeJS BluePrints Chapter 2

I’m trying to use Sequelize on Cloud 9, but I’m getting an error that says my URL must be an object, not a string. It suggests to check the config file, which does have an object, but no URLs… I thought I could add one, but I’m not sure what it’s wanting… the URL to what? my phpAdmin?

turtlewolfe:~/workspace (master) $ sequelize db:migrate

Sequelize CLI [Node: 6.11.2, CLI: 3.2.0, ORM: 1.7.5]

Loaded configuration file "config/config.json".
Using environment "development".

ERROR: Parameter "url" must be a string, not object


  "development": {
    "username": "root",
    "password": "",
    "database": "mvc_mysql_app",
    "host": "",
    "dialect": "mysql"
  "test": {
    "username": "root",
    "password": null,
    "database": "database_test",
    "host": "",
    "dialect": "mysql"
  "production": {
    "username": "root",
    "password": null,
    "database": "database_production",
    "host": "",
    "dialect": "mysql"

it looks like I’m not the first to have this problem


I think I have a solution to this, but I didn’t develop it on my own, so I’ll try to explain and reproduce what I’ve done so far.

For context, I’m currently a student at Viking Code School, and my instructor showed me how to do this. I’m pretty sure he figured it out by diving into the source code for sequelize-cli. He has the patience of a monk. If you want to thank him, he’s @bideowego on GitHub.

So, here goes!

The root cause is that current version sequelize-cli and sequelize are out of sync. Using them together as intended doesn’t always work perfectly. Some commands can be run globally, while others need to be run locally.

When you install sequelize-cli, you can run npm install -g sequelize-cli to make the command available globally. Then, you can run commands like:
sequelize model:create --name User --attributes "name:string"
sequelize seed:create --name users
… so far, these work for me with the global sequelize command. But… eventually, you’ll run into an error like the one above. Then the solution is to start running your commands locally.

To do this, add some scripts to your package.json:

"scripts": {
    "sql:migrate:undo": "npm run sql db:migrate:undo:all",
    "sql:migrate": "npm run sql db:migrate",
    "sql:seed:undo": "npm run sql db:seed:undo:all",
    "sql:seed": "npm run sql db:seed:all",
    "sql:s": "npm run sql:migrate:undo && npm run sql:migrate && npm run sql:seed",
    "sql": "./node_modules/sequelize-cli/lib/sequelize",
    "sqlize:s": "sequelize db:migrate:undo && db:migrate && db:seed:all"

This is the important one:
"sql": "./node_modules/sequelize-cli/lib/sequelize"
It specifies the sequelize file in your node_modules folder through which your commands should be evaluated. I don’t actually know what file is referenced by the sequelize command, but apparently it’s not this one.
One caveat: notice the /lib/ directory in the path above… Sometimes, that’s a /.bin/ instead. I don’t know why that varies, but you’ll want to navigate into your node_modules folder to determine the correct path.

From that point on, you can run any of the above scripts with npm run [script], for example:
npm run sql:s will run npm run sql:migrate:undo && npm run sql:migrate && npm run sql:seed
… and unless you have a separate issue in one of your files, all these commands will execute successfully.

A few more details which may more may not be relevant:
I’m currently using a .sequelizerc file which customizes the paths to my config files. On my first go, I seem to recall I had some difficulty determining the correct location for my config files. Here’s my .sequelizerc (again, credit to @bideowego):

var path = require('path');

// Set options
var config = {
  "config": "./config/sequelize.js",
  "migrations-path": "./migrations/sequelize",
  "seeders-path": "./seeds/sequelize",
  "models-path": "./models/sequelize"

// Resolve paths to absolute paths
Object.keys(config).forEach((key) => {
  config[key] = path.resolve(config[key]);

Notice the config file for sequelize is now called: sequelize.js <-- instead of .json.
That implies the config file is valid JS, not JSON. For me, it looks like this (adding module.exports is the relevant change to make it valid JS):

module.exports = {
  "development": {
  "username": "ubuntu",
  "password": "password",
  "database": "project_mimirs_market_development",
  "host": "",
  "dialect": "postgresql"
  "test": {
    "username": "ubuntu",
    "password": "password",
    "database": "project_mimirs_market_test",
    "host": "",
    "dialect": "postgresql"
  "production": {
    "use_env_variable": "POSTGRES_URL",
    "dialect": "postgres"

Ok! I think that’s it. I’m happy to try and reproduce the commands I’m running if that would be helpful, but I think all the important differences are reflected above.