# Tips on deploying to Heroku

**URL:** <https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047>\
**Category:** I Built This\
**Created:** [June 5, 2016, 3:20pm UTC](https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047 "2016-06-05T15:20:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![r-pr](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/r-pr/32/158855_2.png) [@r-pr](https://forum.freecodecamp.org/u/r-pr)\
**Post date:** [June 5, 2016, 3:20pm UTC](https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047/1 "2016-06-05T15:20:59Z")

</div>

A few days ago I’ve built my first backend project and successfully deployed it to Heroku. That time I strictly followed the instructions given in “Get Set for our Back End Development Projects” challenge. But my second project ([request header parser](https://github.com/r-pr/fcc-headerparser)) I decided to write from scratch, as I thougth that Clementine.js boilerplate gave too much unnecessary functionality for a so simple task. My new app worked fine when run at cloud9, but at Heroku it didn’t. After checking logs I found that I did following mistakes, that prevented my app from working:

1. I hardcoded port number (`app.listen(8080, function() { ...`), while Heroku assigns the port number through evironment variable, so the correct code would be like this: `app.listen(process.env.PORT || 8080 ...`
2. Heroku requires a script thats starts up the app, specified in package.json:  
`... "scripts": { "start": "node your-app-name.js" }`  
After adding this lines my app started to work correctly.

---

<div class="post-metadata">

**Author:** ![CarlJKashnier](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/carljkashnier/32/66471_2.png) [@CarlJKashnier](https://forum.freecodecamp.org/u/CarlJKashnier)\
**Post date:** [June 6, 2016, 5:44am UTC](https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047/2 "2016-06-06T05:44:43Z")

</div>

If you are running linux -t will show the log in realtime when the app starts “running” and will show errors.

---

<div class="post-metadata">

**Author:** ![alodavi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alodavi/32/32571_2.png) [@alodavi](https://forum.freecodecamp.org/u/alodavi)\
**Post date:** [July 11, 2016, 1:56pm UTC](https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047/3 "2016-07-11T13:56:36Z")

</div>

thank you! Your advices helped me deploying my first app! 😃 [https://hello-world-express.herokuapp.com/](https://hello-world-express.herokuapp.com/)

---

<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:** [June 1, 2021, 6:10pm UTC](https://forum.freecodecamp.org/t/tips-on-deploying-to-heroku/8047/4 "2021-06-01T18:10:38Z")

</div>

Closed on June 1, 2021, 6:10pm UTC


