title: Deploying docker flask to heroku get Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
body: <p>I'm sorry if this question similar with many other. But I have so many try to solve this, but not get the correct code to fix this.</p>
  
  <p>I develop flask application use docker-machine and docker swarm. When I run in my local it work perfectly. But when I try deploy to heroku use <code>heroku.yml</code> I get error </p>
  
  <pre><code>Error R10 (Boot timeout) -&gt; Web process failed to bind to $PORT within 60 seconds of launch
  </code></pre>
  
  <p>I'm new to use heroku, so mybe I miss something. I hope advaced can help to see what I miss.</p>
  
  <pre><code>.
  |-- 2019-06-26-17-05-08.076-VBoxSVC-5799.log
  |-- app
  |   |-- app.py
  |   |-- Dockerfile
  |   |-- requirements.txt
  |   '-- static
  |-- docker-compose.yml
  |-- heroku.yml
  |-- nginx
  |   |-- Dockerfile
  |   |-- nginx.conf
  |   '-- smartapp.conf
  '-- README.md
  </code></pre>
  
  <p><strong>./heroku.yml</strong></p>
  
  <pre><code>build:
    docker:
      web: app/Dockerfile
      worker: app/Dockerfile
  </code></pre>
  
  <p><strong>./app/Dockerfile</strong></p>
  
  <pre><code># Use an official Python runtime as a parent image
  FROM python:3.7-slim
  
  # Set the working directory to /app
  WORKDIR /app
  
  # Copy the current directory contents into the container at /app
  COPY . /app
  
  # Install any needed packages specified in requirements.txt
  RUN pip install --trusted-host pypi.python.org -r requirements.txt
  
  # Make port 8000 available to the world outside this container
  #EXPOSE 8000
  
  # Define environment variable
  ENV FLASK_APP=smartapp
  ENV FLASK_ENV=development
  
  # Run run.py when the container launches
  CMD ["gunicorn", "-b", "0.0.0.0", "app:app"]
  </code></pre>
  
  <p><strong>./nginx/Dockerfile</strong></p>
  
  <pre><code>FROM nginx
  RUN rm /etc/nginx/nginx.conf
  COPY nginx.conf /etc/nginx/
  RUN rm /etc/nginx/conf.d/default.conf
  COPY smartapp.conf /etc/nginx/conf.d/
  </code></pre>
  
  <p><strong>./app/app.py</strong></p>
  
  <pre><code>from flask import Flask
  from redis import Redis, RedisError
  import os
  import socket
  
  # Connect to Redis
  redis = Redis(host="redis", db=0, socket_connect_timeout=2, socket_timeout=2)
  
  app = Flask(__name__)
  
  @app.route("/")
  def hello():
      try:
          visits = redis.incr("counter")
      except RedisError:
          visits = "&lt;i&gt;cannot connect to Redis, counter disabled&lt;/i&gt;"
  
      html = "&lt;h3&gt;Hello {name}!&lt;/h3&gt;" \
             "&lt;b&gt;Hostname:&lt;/b&gt; {hostname}&lt;br/&gt;" \
             "&lt;b&gt;Visits:&lt;/b&gt; {visits}"
      return html.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname(), visits=visits)
  
  if __name__ == "__main__":
      # Bind to PORT if defined, otherwise default to 5000.
      port = int(os.environ.get('PORT', 5000))
      app.run(host='0.0.0.0:$PORT')
  </code></pre>
  
  <p><strong>$ heroku logs --tail</strong></p>
  
  <pre><code>2019-06-28T03:47:57.545950+00:00 heroku[web.1]: Starting process with command `gunicorn -b 0.0.0.0 app:app`
  2019-06-28T03:47:59.233102+00:00 app[web.1]: [2019-06-28 03:47:59 +0000] [4] [INFO] Starting gunicorn 19.9.0
  2019-06-28T03:47:59.233716+00:00 app[web.1]: [2019-06-28 03:47:59 +0000] [4] [INFO] Listening at: http://0.0.0.0:8000 (4)
  2019-06-28T03:47:59.233827+00:00 app[web.1]: [2019-06-28 03:47:59 +0000] [4] [INFO] Using worker: sync
  2019-06-28T03:47:59.238431+00:00 app[web.1]: [2019-06-28 03:47:59 +0000] [7] [INFO] Booting worker with pid: 7
  2019-06-28T03:48:57.898890+00:00 heroku[web.1]: State changed from starting to crashed
  2019-06-28T03:48:57.786102+00:00 heroku[web.1]: Error R10 (Boot timeout) -&gt; Web process failed to bind to $PORT within 60 seconds of launch
  2019-06-28T03:48:57.786193+00:00 heroku[web.1]: Stopping process with SIGKILL
  2019-06-28T03:48:57.883116+00:00 heroku[web.1]: Process exited with status 137
  2019-06-28T03:48:58.833786+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quiet-cove-70697.herokuapp.com request_id=a0fd1087-0ac8-44c8-ac31-cb43a46a9449 fwd="103.7.225.121" dyno= connect= service= status=503 bytes= protocol=https
  2019-06-28T03:48:59.820240+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quiet-cove-70697.herokuapp.com request_id=cd9bce77-f818-4516-b2b0-333ab2b95eea fwd="103.7.225.121" dyno= connect= service= status=503 bytes= protocol=https
  2019-06-28T03:49:15.792328+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quiet-cove-70697.herokuapp.com request_id=4ba13aa2-f739-4792-9859-9ad86d9da38b fwd="103.7.225.121" dyno= connect= service= status=503 bytes= protocol=https
  2019-06-28T03:49:16.883549+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quiet-cove-70697.herokuapp.com request_id=1acbfe60-2023-42d5-8091-826d0156d765 fwd="103.7.225.121" dyno= connect= service= status=503 bytes= protocol=https
  2019-06-28T03:55:22.425339+00:00 heroku[web.1]: State changed from crashed to starting
  2019-06-28T03:55:25.634810+00:00 heroku[web.1]: Starting process with command `gunicorn -b 0.0.0.0 app:app`
  2019-06-28T03:55:27.616318+00:00 app[web.1]: [2019-06-28 03:55:27 +0000] [4] [INFO] Starting gunicorn 19.9.0
  2019-06-28T03:55:27.616885+00:00 app[web.1]: [2019-06-28 03:55:27 +0000] [4] [INFO] Listening at: http://0.0.0.0:8000 (4)
  2019-06-28T03:55:27.616984+00:00 app[web.1]: [2019-06-28 03:55:27 +0000] [4] [INFO] Using worker: sync
  2019-06-28T03:55:27.621084+00:00 app[web.1]: [2019-06-28 03:55:27 +0000] [7] [INFO] Booting worker with pid: 7
  2019-06-28T03:56:25.725581+00:00 heroku[web.1]: Error R10 (Boot timeout) -&gt; Web process failed to bind to $PORT within 60 seconds of launch
  2019-06-28T03:56:25.725672+00:00 heroku[web.1]: Stopping process with SIGKILL
  2019-06-28T03:56:25.821622+00:00 heroku[web.1]: State changed from starting to crashed
  2019-06-28T03:56:25.799366+00:00 heroku[web.1]: Process exited with status 137
  </code></pre>
  
  <p>Thank's</p>