# URL shortener - application error deploying with heroku

**URL:** <https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380>\
**Category:** General\
**Created:** [March 7, 2017, 11:18am UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380 "2017-03-07T11:18:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![harveywun](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harveywun](https://forum.freecodecamp.org/u/harveywun)\
**Post date:** [March 7, 2017, 11:18am UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/1 "2017-03-07T11:18:25Z")

</div>

Finished and works perfectly with cloud9.

But having trouble deploying with heroku. The error log is not descriptive at all:

```
2017-03-07T10:55:14.282664+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-07T10:55:14.269831+00:00 heroku[web.1]: Process exited with status 1
2017-03-07T10:55:17.646187+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fcc-shortenurl.herokuapp.com request_id=0a7b28a5-fdf3-4a88-971c-cecd748f1ea4 fwd="58.152.144.225" dyno= connect= service= status=503 bytes=
2017-03-07T10:55:19.254197+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fcc-shortenurl.herokuapp.com request_id=164d5ff9-f0fc-43bd-a876-9ad5b507e42e fwd="58.152.144.225" dyno= connect= service= status=503 bytes=

```

Not sure what else to add since the log is not very useful. Any idea how to proceed?

The only change I’ve made to code before deploying is:

- Changed to: app.listen(process.env.PORT)
- Added to package.json:  
“scripts”: {  
“start”: “node server.js”  
}

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [March 7, 2017, 11:32am UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/2 "2017-03-07T11:32:20Z")

</div>

It should be `process.env.PORT`

---

<div class="post-metadata">

**Author:** ![harveywun](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harveywun](https://forum.freecodecamp.org/u/harveywun)\
**Post date:** [March 7, 2017, 11:50am UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/3 "2017-03-07T11:50:45Z")

</div>

Sry, just a typo on my part. I have “process.env.PORT” in my code. This isn’t the issue.

---

<div class="post-metadata">

**Author:** ![harveywun](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harveywun](https://forum.freecodecamp.org/u/harveywun)\
**Post date:** [March 7, 2017, 11:53am UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/4 "2017-03-07T11:53:16Z")

</div>

Ok. I opened up Heroku toolbelt. The log is more descriptive:

```
2017-03-07T11:46:06.000000+00:00 app[api]: Build succeeded
2017-03-07T11:46:18.049037+00:00 heroku[web.1]: Starting process with command `npm start`
2017-03-07T11:46:21.016855+00:00 app[web.1]:
2017-03-07T11:46:21.016890+00:00 app[web.1]: > shorturl@1.0.0 start /app
2017-03-07T11:46:21.016891+00:00 app[web.1]: > node server.js
2017-03-07T11:46:21.016892+00:00 app[web.1]:
2017-03-07T11:46:21.233409+00:00 app[web.1]: module.js:471
2017-03-07T11:46:21.233412+00:00 app[web.1]: throw err;
2017-03-07T11:46:21.233413+00:00 app[web.1]: ^
2017-03-07T11:46:21.233413+00:00 app[web.1]:
2017-03-07T11:46:21.233414+00:00 app[web.1]: Error: Cannot find module 'mongodb'
2017-03-07T11:46:21.233415+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-03-07T11:46:21.233416+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-03-07T11:46:21.233417+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-07T11:46:21.233417+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-07T11:46:21.233418+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:9:15)
2017-03-07T11:46:21.233419+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-07T11:46:21.233419+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-07T11:46:21.233420+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-07T11:46:21.233422+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-03-07T11:46:21.233421+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-07T11:46:21.244651+00:00 app[web.1]:
2017-03-07T11:46:21.252465+00:00 app[web.1]: npm ERR! Linux 3.13.0-110-generic
2017-03-07T11:46:21.252678+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-07T11:46:21.252831+00:00 app[web.1]: npm ERR! node v6.10.0
2017-03-07T11:46:21.253000+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-03-07T11:46:21.253133+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-07T11:46:21.253432+00:00 app[web.1]: npm ERR! shorturl@1.0.0 start: `node server.js`
2017-03-07T11:46:21.253824+00:00 app[web.1]: npm ERR! Failed at the shorturl@1.0.0 start script 'node server.js'.
2017-03-07T11:46:21.253559+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-07T11:46:21.253973+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-07T11:46:21.253664+00:00 app[web.1]: npm ERR!
2017-03-07T11:46:21.254060+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the shorturl package,
2017-03-07T11:46:21.254142+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-07T11:46:21.254243+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-07T11:46:21.254330+00:00 app[web.1]: npm ERR! node server.js
2017-03-07T11:46:21.254414+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-07T11:46:21.254500+00:00 app[web.1]: npm ERR! npm bugs shorturl
2017-03-07T11:46:21.254622+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-07T11:46:21.254796+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-07T11:46:21.259433+00:00 app[web.1]:
2017-03-07T11:46:21.254706+00:00 app[web.1]: npm ERR! npm owner ls shorturl
2017-03-07T11:46:21.259755+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-03-07T11:46:21.259684+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-07T11:46:21.428424+00:00 heroku[web.1]: Process exited with status 1
2017-03-07T11:46:21.458386+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-07T11:46:21.459759+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-07T11:46:22.970103+00:00 heroku[web.1]: Starting process with command `npm start`
2017-03-07T11:46:24.772464+00:00 app[web.1]: > shorturl@1.0.0 start /app
2017-03-07T11:46:24.772465+00:00 app[web.1]: > node server.js
2017-03-07T11:46:24.772452+00:00 app[web.1]:
2017-03-07T11:46:24.772466+00:00 app[web.1]:
2017-03-07T11:46:24.933486+00:00 app[web.1]: module.js:471
2017-03-07T11:46:24.933488+00:00 app[web.1]: throw err;
2017-03-07T11:46:24.933489+00:00 app[web.1]: ^
2017-03-07T11:46:24.933490+00:00 app[web.1]:
2017-03-07T11:46:24.933490+00:00 app[web.1]: Error: Cannot find module 'mongodb'
2017-03-07T11:46:24.933491+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-03-07T11:46:24.933491+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-03-07T11:46:24.933492+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-03-07T11:46:24.933492+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-03-07T11:46:24.933492+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:9:15)
2017-03-07T11:46:24.933493+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-03-07T11:46:24.933493+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-03-07T11:46:24.933494+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-03-07T11:46:24.933494+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-03-07T11:46:24.933495+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-03-07T11:46:24.939990+00:00 app[web.1]:
2017-03-07T11:46:24.947007+00:00 app[web.1]: npm ERR! Linux 3.13.0-110-generic
2017-03-07T11:46:24.947262+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-07T11:46:24.947493+00:00 app[web.1]: npm ERR! node v6.10.0
2017-03-07T11:46:24.947684+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-03-07T11:46:24.947875+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-07T11:46:24.948144+00:00 app[web.1]: npm ERR! shorturl@1.0.0 start: `node server.js`
2017-03-07T11:46:24.948285+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-07T11:46:24.948434+00:00 app[web.1]: npm ERR!
2017-03-07T11:46:24.948572+00:00 app[web.1]: npm ERR! Failed at the shorturl@1.0.0 start script 'node server.js'.
2017-03-07T11:46:24.948707+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-07T11:46:24.948854+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the shorturl package,
2017-03-07T11:46:24.949131+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-07T11:46:24.949265+00:00 app[web.1]: npm ERR! node server.js
2017-03-07T11:46:24.948988+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-07T11:46:24.949401+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-07T11:46:24.949534+00:00 app[web.1]: npm ERR! npm bugs shorturl
2017-03-07T11:46:24.949666+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-07T11:46:24.949789+00:00 app[web.1]: npm ERR! npm owner ls shorturl
2017-03-07T11:46:24.949919+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-07T11:46:24.953291+00:00 app[web.1]:
2017-03-07T11:46:24.953488+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-07T11:46:24.953602+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-03-07T11:46:25.024766+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-07T11:46:25.010667+00:00 heroku[web.1]: Process exited with status 1
2017-03-07T11:46:26.211765+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fcc-shortenurl.herokuapp.com request_id=21e6e167-93a2-4b59-a9d0-525797f5bcdc fwd="58.152.144.225" dyno= connect= service= status=503 bytes=
2017-03-07T11:46:27.767804+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fcc-shortenurl.herokuapp.com request_id=58ced9be-dca0-47b9-a1be-6bc0ab884371 fwd="58.152.144.225" dyno= connect= service= status=503 bytes=
```

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [March 7, 2017, 12:02pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/5 "2017-03-07T12:02:20Z")

</div>

Do you have your code on GitHub or something?

---

<div class="post-metadata">

**Author:** ![harveywun](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harveywun](https://forum.freecodecamp.org/u/harveywun)\
**Post date:** [March 7, 2017, 12:08pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/6 "2017-03-07T12:08:26Z")

</div>

> **[harveywun/shorturl](https://github.com/harveywun/shorturl)**
>
> Contribute to shorturl development by creating an account on GitHub.

Yes. Please ignore the security issue with user:password, trying to debug this and disabled .env.

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [March 7, 2017, 12:11pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/7 "2017-03-07T12:11:24Z")

</div>

You forgot to add `mongodb` as a dependency in `package.json`.

---

<div class="post-metadata">

**Author:** ![harveywun](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harveywun](https://forum.freecodecamp.org/u/harveywun)\
**Post date:** [March 7, 2017, 12:20pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/8 "2017-03-07T12:20:51Z")

</div>

Finally! Works now. Thanks.

Quick question - If I left out the dependency, why would it work with cloud9 and not heroku then?

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [March 7, 2017, 12:24pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/9 "2017-03-07T12:24:59Z")

</div>

I suppose `mongodb` was already downloaded to your local `node_modules` folder.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:58pm UTC](https://forum.freecodecamp.org/t/url-shortener-application-error-deploying-with-heroku/94380/10 "2021-01-16T17:58:38Z")

</div>

Closed on January 16, 2021, 5:58pm UTC


