i am having a problem deploying my app on heroku (node.js) - node.js

hi i am getting a problem while trying to deploy my app on heruko
the following error
and my Procfile looks like
web: npm start
2019-10-25T03:31:44.445209+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=andela-api.herokuapp.com request_id=ee3f68c6-e7a5-4212-8277-bddd8a33027c fwd="41.186.25.0" dyno= connect= service= status=503 bytes= protocol=https```

Favicon file is an image file(usually website logo) that you see on the browser tab. It has extension .ico. Your project cannot find that file.
If you do not have favicon.ico file in your project, then create one and upload it at suitable location(make sure it's accessible via url /favicon.ico).
If you have favicon file in your project, the problem is related to permission to access the file via /favicon.ico (make sure the folder where you have the file stored is public so that it can be access via url /favicon.ico)
How to create favicon file?
Use favicon generator site such this one. Upload your logo file and download the favicon generated by the site.

I had react app and after deploying to heroku I got the same error. The reason of this, I deleted favicon.ico and manifest.json files in public folder. After adding favicon.ico and manifest.json files in public folder, the error solved.

Related

Node Express server works in Heroku staging pipeline but not on production pipeline (no such app error)

I developed an api with nodejs, express and run (npm start) with pm2 (link). I published the app on heroku in a pipeline, I use the staging and production pipeline. The staging app works fine, but the production app is very inconsistent, succeeding sometimes and failing most.
Below the api access log, in the second request there is an error 404 with "no such app" in the html body error message (it is not in the image log).
2021-11-22T12:52:37.266486+00:00 app[web.1]: Starting server in port 12080
2021-11-22T12:52:37.567394+00:00 heroku[router]: at=info method=POST path="/token" host={hidden}-production.herokuapp.com request_id={hidden} fwd="{hidden}" dyno=web.1ect=0ms service=692ms status=200 bytes=613 protocol=https
2021-11-22T12:53:12.688593+00:00 heroku[router]: at=info method=POST path="/token" host={hidden}-production.herokuapp.com request_id={hidden} fwd="{hidden}" dyno=web.1 connect=0ms service=35ms status=404 bytes=711 protocol=https
I believe it is not a route problem, it works sometimes and in staging it works fine. I'm using Heroku's promotion button (staging -> production).
Is there a problem with Heroku?
Are any different configurations required for the application in production?
The problem was in my app syncing with the Heroku routers.
Was fixed by the Heroku team itself.

How to make my app on Heroku stop timing out

I made a simple financial app consisting of a React frontend and Node/express backend that I want to deploy to Heroku. Since it's a small app I put everything (server as well as client files) in the root directory of my git repository. Thus the entry files for frontend (index.html), backend (index.js) and the Procfile required by Heroku are all in the root directory.
The server seems to be working fine, since I can successfully make requests from the locally installed frontend. However it appears that the server cannot serve the static files.
This is the log message from heroku:
2021-07-29T15:21:00.260957+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=xpensoft.herokuapp.com request_id=2a484f4d-30cf-49b9-920d-14b9e9be28fb fwd="31.151.16.151" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
I am serving the static files using this server code:
if (process.env.NODE_ENV === 'production') {
app.use(express.static(__dirname));
}
Anyone has any idea what could be causing the timeout?
EDIT:
Apart from the code above, which is supposed to serve up the static files (which is unfortunately doesn't) there is no specific code in the server file handling the '/' endpoint. There is only code for specific named endpoints.
In the React app I am redirecting the user using React Router:
<Route exact path='/'>
<Redirect to='/user' />
</Route>
However the React app is never loaded.
request timeout error comes when your app takes more than 30 seconds to send a response back to the client.
So there is some issue with your code which handles the '/' route.
if Your static files are facing issues to get served up, it's most probably the issues with .env file. So manually add the enviorment variables in Heroku Settings > Config Vars

Heroku App rollback works but identical code does not - works perfectly locally

I have a Node.js app running a React front-end hosted on Heroku which is linked to a Github repository so that on push it redeploys the app. I have been using the app this way without problem for around a year now.
It works on Heroku Local, and running the node app locally without Heroku but I'm getting a 503 service unavailable error when I run a put request when running the app online.
2021-06-01T08:04:27.326913+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=PUT path="/api/auth/login" host=myapp.herokuapp.com request_id=9b84f5c5-def4-4dce-82d2-baf1bef3a9a8 fwd="90.215.204.78" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
Any pointers?
It was fixed by adding a Procfile with: "web:server/index.js" as well as specifying the Node version specifically changing the code in my package.json from:
"engine":"12.x",
to:
"engines": {
"node":"v12.18.3"
},
I think it is likely the package.json change that ultimately fixed the problem.

code=H10 desc="App crashed" method=GET path="/", trying to upload my project on heroku

So, I have successfully uploaded my whole project(angular + node files) on heroku, I have also uploaded my mongodb database on mlab. But my app always gets crashed.
Here is the heroku log:
I have already tried changing ports to--> log.Fatal(http.ListenAndServe(":" + os.Getenv("PORT"), router)), it seems to work for most of them but not for me.
I have also removed engine section from package.json. Still no luck. Any help would be really appreciated.

Application Error on new Heroku app

I know this question has been answered a lot, but I still can't figure out a solution to my problem. I've created a little app which is supposed to work with the Slack webhook. Locally, it works just fine - I use node app in order to launch it.
I've created my app on Heroku, pushed my files (Procfile app.js hellobot.js package.json)
But when I visit http://slackbot2.herokuapp.com/, I get an Application Error message.
I already tried the log but I get this :
2015-06-11T23:39:05.967607+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=slackbot2.herokuapp.com request_id=b3783c70-306b-4528-9d81-4e8ab43e9132 fwd="*******" dyno= connect= service= status=503 bytes=
This heroku run rails console and heroku run rake db:migrate won't work. bash: rails command not found. Rails and Rake are installed on my Mac (OSX 10.10.4). Those were the only solutions that worked for others .. But not me.
Same thing happened with me. As far as I can remember, the reason for this is the port you used in the application. Heroku will not run your app on port 8080 or 3000, instead it will be some random port. Use this code to fix the problem.
var port = process.env.PORT || 8080;
Use this code to start the server.
app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});

Resources