Heroku : Application error : error code=H12 desc=”Request timeout” : when using remote database
I was working with a Node application I built, which connected to a hosted MongoDB database. Everything worked perfectly on my development machine. Once I pushed everything to heroku is where I would start getting problems.
I received this error after trying to connect to my apps webpage
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
When checking the logs this error stood out
2019-08-01T18:36:14.968797+00:00 heroku[router]: at=error code=H12 desc=”Request timeout” method=GET path=”/api/notes” host=spongebobs-basin
-47509e646.herokuapp.com request_id=e70f60dc-321d-421c-9c24-6974ba3a79bb fwd=”220.127.116.11″ dyno=web.1 connect=0ms service=30000ms status=503 b
So what are the important things in this line?
- desc=”Request timeout”
- method=GET path=”/api/notes”
- status=503 b
I am connecting to the correct path, using the correct method, but after 30 seconds the server is timing out , so heroku sends a 503 Service Unavailable.
This was a strange one to figure out since locally everything worked great. I changed some things around for testing and found that the application on heroku was not connecting to the remote mongoDB host. Locally it worked great. Was this a herkoku problem?
The .env file I used locally required the mongoDB URI to be in quotes. The app would not work without the quotes. But the configuration variables in heroku needed to be added without the quotes.
- .env ‘mongodb+srv://username:firstname.lastname@example.org/note-app’
- Config Vars mongodb+srv://username:email@example.com/note-app
One thought on “Heroku : Application error : error code=H12 desc=”Request timeout” : when using remote database”
May 28, 2020 at 12:51 pm