Solving H-10 Error for Heroku Deployment
Tags: javascript, beginners, heroku, react
Published: 2022-09-24 18:45:14

Hi Dev Community! 

If you’ve found this blog post, I can already sense your frustration. Are you at the end of your rope with this error?

Maybe you’re a beginner or attending a bootcamp, like myself, and you’re ready to deploy your first app. Heroku was recommended and all the videos and tutorials made it seem straightforward enough. You followed the directions step by step and you’re _meticulous_ and _careful_ because you know how one typo can send you down a spiral.

Success! You receive the following confirmation:

```
-----> Build succeeded!
...
-----> Verifying deploy.... done.
-----> Running release command...
----->Waiting for release.... Done.

```

Excited it that it seemed to work on your first try, you command `heroku open` and you get the following...


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ufr1cb0ht2n641nwhnln.png)

And you run ​​`heroku logs --tail` as you’re told and get something similar to the following:

```
2022-09-21T22:11:34.028636+00:00 heroku[web.1]: Process exited with status 1
2022-09-21T22:11:34.088522+00:00 heroku[web.1]: State changed from starting to crashed
2022-09-21T22:11:35.045857+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=book-worm-hole.herokuapp.com request_id=f3e2af21-0107-4e02-b791-9b172d4dc646 fwd="97.98.68.225" dyno= connect= service= status=503 bytes= protocol=https
2022-09-21T22:11:35.883219+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=book-worm-hole.herokuapp.com request_id=ac2ff6bc-db19-43c4-936b-d25f8de1b4af fwd="97.98.68.225" dyno= connect= service= status=503 bytes= protocol=https
```

Listen, I just went down this spiral. Hopefully, I can guide you on how to troubleshoot and identify what’s causing this. But a warning...this error is a maze that can end with many solutions. Google will still be your friend in the end!

Let’s get started!

### What is the H-10 error?

Heroku provides the following, limited, information regarding this error:

> A crashed web dyno or a boot timeout on the web dyno will present this error. [Heroku Error Codes](https://devcenter.heroku.com/articles/error-codes)

To break this down, “Dynos” are Heroku designed, Linux containers designed to execute your code based on user-commands ([resource](https://www.heroku.com/dynos)).These are defined through your Procfile, but not necessarily where the issue lies. 


"Boot timeout" is what it sounds like. The error is because Heroku is not able to configure on which PORT to run the application.

If your errors from `heroku logs --tail` match the above, we are solving for crashed web dynos.

### Troubleshooting Steps:

#### 1. Run heroku run rails console.
  This was one of the more helpful tips I’ve found! If your 
  errors are similar to mine, running this command will 
  provide more specific errors.

  My command returned the following (but yours may return differently):

```
/app/vendor/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require': cannot load such file -- net/pop (LoadError)
....
6.1.7/lib/rails/command.rb:48:in `invoke'
        from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.7/lib/rails/commands.rb:18:in `<top (required)>'
        from /app/bin/rails:5:in `require'
        from /app/bin/rails:5:in `<main>'
```

#### 2. Google! 
 There is a lot you can google within this error. Depending on 
 what you copy and search, you may get different solutions. A 
 tip I learned from an instructor is to find that first error 
 line and google the bolded terms or the tail end of the error.

 Example: "cannot load such file -- net/pop"

### Solutions:

1. Googling the above brought me to understand there were gems 
 missing from my Gemfile:

```
gem 'net-smtp'
gem 'net-imap'
gem 'net-pop'
```
While friends and instructors did not need the above, I was 
explained that different versions of rails and ruby could 
conflict with each other. Updated versions may not have the 
correct gemfiles built in which could then require you to 
manually add them as I had to.

2. There are general causes for the H-10 errors, I recommend the following resources. 
NOTE: solutions may be outdated so I would run general commands vs. plugging in every suggestion.
- [“Causes of Heroku H10-App Crashed Error And How To Solve Them” -  Lawrence Eagles](https://dev.to/lawrence_eagles/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-3jnl)

- [Causes of Heroku H10-App Crashed Error And How To Solve Them | Top 3 error newbies always have - HaryPhamDev](https://www.youtube.com/watch?v=68iCwSmSIvA)

Many comment their success with these steps but the solutions did not provide success in my case.

### Conclusion:

The H-10 was extremely frustrating for myself to solve! Others who experienced this issue in my cohort were not able to resolve either and resorted to other options. This is a perfectly acceptable solution as the time spent troubleshooting this could have been spent elsewhere. In the end, the potential issues can be so different from one project to the next that I don't believe this issue and documentation provided by Heroku is beginner friendly.
 
With that said, I learned valuable information on appropriate googling and error handling research.

I hope this finds that one engineer out there who is in google spiral as I was!