2

I have a node.js server run successfully in localhost. But when I deploy to Heroku, server is crashed. I have check that the local and heroku have the same node.js and npm version. Hope receive your advises. Thank you.

Here is the message logs:

2017-01-13T04:16:32.949664+00:00 app[web.1]: > [email protected] start /app
2017-01-13T04:16:32.949665+00:00 app[web.1]: > node server.js
2017-01-13T04:16:32.949665+00:00 app[web.1]: 
2017-01-13T04:16:33.344617+00:00 app[web.1]: url.js:87
2017-01-13T04:16:33.344629+00:00 app[web.1]:     throw new TypeError('Parameter "url" must be a string, not ' + typeof url);
2017-01-13T04:16:33.344630+00:00 app[web.1]:     ^
2017-01-13T04:16:33.344631+00:00 app[web.1]: 
2017-01-13T04:16:33.344633+00:00 app[web.1]: TypeError: Parameter "url" must be a string, not undefined
2017-01-13T04:16:33.344634+00:00 app[web.1]:     at Url.parse (url.js:87:11)
2017-01-13T04:16:33.344636+00:00 app[web.1]:     at Object.urlParse [as parse] (url.js:81:5)
2017-01-13T04:16:33.344636+00:00 app[web.1]:     at new Sequelize (/app/node_modules/sequelize/lib/sequelize.js:125:24)
2017-01-13T04:16:33.344637+00:00 app[web.1]:     at Object.<anonymous> (/app/db.js:6:17)
2017-01-13T04:16:33.344638+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-01-13T04:16:33.344638+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-01-13T04:16:33.344639+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-01-13T04:16:33.344640+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-01-13T04:16:33.344640+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
2017-01-13T04:16:33.344641+00:00 app[web.1]:     at Module.require (module.js:497:17)
2017-01-13T04:16:33.344642+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-01-13T04:16:33.344642+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:1:72)
2017-01-13T04:16:33.344643+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-01-13T04:16:33.344643+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-01-13T04:16:33.344644+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-01-13T04:16:33.344645+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-01-13T04:16:33.353999+00:00 app[web.1]: 
2017-01-13T04:16:33.362350+00:00 app[web.1]: npm ERR! Linux 3.13.0-105-generic
2017-01-13T04:16:33.362417+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-01-13T04:16:33.362573+00:00 app[web.1]: npm ERR! node v6.9.4
2017-01-13T04:16:33.362726+00:00 app[web.1]: npm ERR! npm  v4.1.1
2017-01-13T04:16:33.362920+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-01-13T04:16:33.363075+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js`
2017-01-13T04:16:33.363192+00:00 app[web.1]: npm ERR! Exit status 1
2017-01-13T04:16:33.363477+00:00 app[web.1]: npm ERR! 
2017-01-13T04:16:33.363609+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node server.js'.
2017-01-13T04:16:33.363736+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-01-13T04:16:33.363916+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the golaundryserver package,
2017-01-13T04:16:33.364086+00:00 app[web.1]: npm ERR! not with npm itself.
2017-01-13T04:16:33.364367+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-01-13T04:16:33.364662+00:00 app[web.1]: npm ERR!     node server.js
2017-01-13T04:16:33.365384+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-01-13T04:16:33.365555+00:00 app[web.1]: npm ERR!     npm bugs golaundryserver
2017-01-13T04:16:33.365732+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-01-13T04:16:33.365933+00:00 app[web.1]: npm ERR!     npm owner ls golaundryserver
2017-01-13T04:16:33.366104+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-01-13T04:16:33.370608+00:00 app[web.1]: 
2017-01-13T04:16:33.370806+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-01-13T04:16:33.370908+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-01-13T04:16:33.450002+00:00 heroku[web.1]: Process exited with status 1
2017-01-13T04:16:33.423935+00:00 heroku[web.1]: State changed from starting to crashed

1 Answer 1

1

From the errors that you showed my assumption is that the database connection string that you pass to Sequelize in line 6 of /app/db.js is not defined on Heroku, even though it's defined on your machine.

The possible reasons for that could be that you get it from an environment variable or some config file that is available on your machine but isn't available on the Heroku instance.

See how Sequelize is initialized in /app/db.js, where the URL comes from, maybe add some console.log(YOUR_VARIABLE_NAME) there and then try to make sure that it is defined as it should.

You can set your environments on Heroku in the dashboard so that you don't have to put any credentials in the source code, see:

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

1 Comment

thank you so much, I realize that my code at connecting to DB has some errors.

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.