Im trying to deploy simple CRUD node js API to heroku but always get app crashed h10,
It work in local https://i.sstatic.net/56GNF.png .But get this error when i deploy it https://i.sstatic.net/KbZzJ.png.
Procfile
web:node app.js
I am already tried web: node app.js
, web: yarn start
, web:yarn start
and still got same error
Package.JSON
{
"name": "servis-invoice",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "nodemon app.js",
"start": "node app.js"
},
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.11.18",
"mongoose-delete": "^0.5.3",
"nodemon": "^2.0.7"
}
}
My config vars: https://i.sstatic.net/K7f0K.jpg
Is i am missing any steps?
I am using yarn but i dont know why heroku using npm start in deploy?
In the logs you see the (famous) error web process failed to bind to $port
which means your application does not bind to the port provided by Heroku
Use process.env.PORT
to define the port the application listens to
See Heroku: Why is my Node.js app crashing with an R10 error? NodeJS documentation