Home > front end >  How to get rid of application error in heroku when running
How to get rid of application error in heroku when running

Time:11-24

I deployed this app on Heroku for the first time 6 months ago and it was running fine. Its still running fine on localhost but now when I try to use the same heroku link its showing application error.

Here are my logs:

heroku logs --tail
2021-11-22T21:25:37.247493 00:00 heroku[web.1]: Restarting
2021-11-22T21:25:37.291674 00:00 heroku[web.1]: State changed from up to starting
2021-11-22T21:25:38.213115 00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-11-22T21:25:38.434284 00:00 heroku[web.1]: Process exited with status 143
2021-11-22T21:25:39.432521 00:00 heroku[web.1]: Starting process with command `node app.js`
2021-11-22T21:25:40.721334 00:00 app[web.1]: Database_URL undefined
2021-11-22T21:25:40.722187 00:00 app[web.1]: Server has started
2021-11-22T21:25:41.145424 00:00 heroku[web.1]: State changed from starting to up
2021-11-22T21:26:10.715356 00:00 app[web.1]: connect ECONNREFUSED 127.0.0.1:27017
2021-11-22T21:26:20.762822 00:00 heroku[router]: at=info method=GET path="/" host=sleepy-basin-23202.herokuapp.com request_id=9145c837-b0b8-409e-af04-38431cef02a5 fwd="47.15.8.93" dyno=web.1 connect=0ms service=12ms status=304 bytes=151 protocol=https
2021-11-22T21:26:21.119967 00:00 heroku[router]: at=info method=GET path="/style.css" host=sleepy-basin-23202.herokuapp.com request_id=7cd5ff7a-a627-4f97-a28f-b4f73b08b463 
fwd="47.15.8.93" dyno=web.1 connect=0ms service=9ms status=200 bytes=4543 protocol=https
2021-11-22T21:26:21.123105 00:00 heroku[router]: at=info method=GET path="/script.js" host=sleepy-basin-23202.herokuapp.com request_id=3176b0d8-80b4-4c6c-a389-cc786bbd0e0f 
fwd="47.15.8.93" dyno=web.1 connect=0ms service=7ms status=404 bytes=392 protocol=https
2021-11-22T21:26:21.452457 00:00 heroku[router]: at=info method=GET path="/script.js" host=sleepy-basin-23202.herokuapp.com request_id=cbdc660f-90e1-443b-8b2d-2f255018b63d 
fwd="47.15.8.93" dyno=web.1 connect=0ms service=2ms status=404 bytes=392 protocol=https
2021-11-22T21:26:22.904249 00:00 heroku[router]: at=info method=POST path="/view" host=sleepy-basin-23202.herokuapp.com request_id=3a4c38b1-5798-490e-bc1b-73338fc18cf5 fwd="47.15.8.93" dyno=web.1 connect=0ms service=13ms status=302 bytes=246 protocol=https
2021-11-22T21:26:33.202949 00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: MongooseError: Operation `users.find()` buffering timed out after 10000ms
2021-11-22T21:26:33.202957 00:00 app[web.1]: at Timeout.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:185:20)
2021-11-22T21:26:33.202958 00:00 app[web.1]: at listOnTimeout (internal/timers.js:554:17)
2021-11-22T21:26:33.202959 00:00 app[web.1]: at processTimers (internal/timers.js:497:7)
2021-11-22T21:26:33.202960 00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-11-22T21:26:33.203001 00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2021-11-22T21:26:33.203100 00:00 app[web.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are 
not handled will terminate the Node.js process with a non-zero exit code.
2021-11-22T21:26:53.190725 00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/view" host=sleepy-basin-23202.herokuapp.com request_id=23595d4a-6e69-48cf-a1ce-2ef12ce13815 fwd="47.15.8.93" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https

CodePudding user response:

It can't find you database Url check your env configuration

CodePudding user response:

There isn't much information here, but I see

Database_URL undefined

in your logs. Assuming you are using a Heroku database addon like Heroku Postgres, your database URL will be defined in a variable called DATABASE_URL. Case is important: DATABASE_URL and Database_URL are different things.

Please update your code to use DATABASE_URL.

Note that environment variable names are not case-sensitive on Windows. If you are using Windows for local development that's one reason this might work locally and not work on Heroku.

  • Related