Error trying to deploy to Heroku

Hi there!

I’m trying to deploy a Telegram Bot to Heroku using ExGram with the following repo.
I’m not using Phoenix, do I need it for this?
In my config.exs, I only have:

import Config

config :ex_gram, token: System.fetch_env!("BOT_TOKEN")

The bot works fine locally, but when I deploy it with Heroku, I get the following error:

2022-01-29T14:58:16.594522+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-01-29T14:58:16.622447+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-01-29T14:58:16.756426+00:00 heroku[web.1]: Process exited with status 137
2022-01-29T14:58:16.814441+00:00 heroku[web.1]: State changed from starting to crashed

The bot seems to run for a couple of seconds before the error.
Maybe I’m missing something in my configuration?
I’m starting it with with mix run --no-halt, is this the way to do it?
I have tried googling this issue but every answer that comes up is about Elixir + Phoenix.
Please, let me know if you need more information to answer me and thanks :slight_smile: .

Heroku is complaining that it can’t contact your app’s HTTP endpoint on the port that it assigned to your app ($PORT).

If your app is a web app, you need to configure it to listen to that port. If not, you could try telling Heroku that the process type is worker by updating your Procfile.

Hi, thanks for the answer :slight_smile:.

Yes, seems like I need to configure the app to listen to $PORT. But I can’t figure out how to to do it. Do I have to use some dependency, or to configure it via Elixir somehow?

Sorry, I’m kinda new to this.

Since you’re new I’d recommend using Phoenix because there’s lots of guides for running Phoenix in production:

But you can also adapt those for your chosen web server.

1 Like