title: Error in deploy Gunicorn and Supervisor on AWS EC2
body: <p>I'm new to this, so please be patient </p>
  
  <p>I am trying to deploy a flask app using AWS Ubuntu machine with open ports 
   <strong>443</strong> and <strong>80</strong></p>
  
  <p>when I run the flask app using <code>sudo python app.py</code> it works.</p>
  
  <p>The problem appears when I try to use <code>gunicorn</code>. when I use the command <br></p>
  
  <pre><code>gunicorn -b 0.0.0.0:443 app:app
  </code></pre>
  
  <p>it pushes this error </p>
  
  <pre><code>[2018-06-18 13:30:30 +0000] [11135] [INFO] Starting gunicorn 19.8.1
  [2018-06-18 13:30:30 +0000] [11135] [ERROR] Retrying in 1 second.
  [2018-06-18 13:30:31 +0000] [11135] [ERROR] Retrying in 1 second.
  [2018-06-18 13:30:32 +0000] [11135] [ERROR] Retrying in 1 second.
  [2018-06-18 13:30:33 +0000] [11135] [ERROR] Retrying in 1 second.
  [2018-06-18 13:30:34 +0000] [11135] [ERROR] Retrying in 1 second.
  [2018-06-18 13:30:35 +0000] [11135] [ERROR] Can't connect to ('0.0.0.0', 443)
  </code></pre>
  
  <p>I have checked that no process listen to port <strong>443</strong> using <code>lsof -i:443</code></p>
  
  <p>Here is app.py </p>
  
  <pre><code>from flask import Flask
  application = Flask(__name__)
  
  @application.route("/")
  def index():
      return "Hello World!"
  
  if __name__ == "__main__":
      application.run(host='0.0.0.0', port='443')
  </code></pre>
  
  <p><strong>Edited</strong>  : gunicorn error solved by installing it using <code>sudo -H pip install gunicorn</code>  </p>
  
  <p>I am trying to deploy app in production so i want it continuously running . i tried <code>supervisor</code> to keep it up all the time </p>
  
  <p>Here is the configuration of <code>supervisor</code></p>
  
  <pre><code>[program:app_name]
  directory=/home/ubuntu/FIFA_Captcha
  command=/usr/local/bin/gunicorn -b 0.0.0.0:443 app:app
  autostart=true
  user=root
  autorestart=true
  stderr_logfile=/home/ubuntu/app_name.err.log
  stdout_logfile=/home/ubuntu/app_name.out.log
  environment=PYTHONPATH=/usr/bin/python
  </code></pre>
  
  <p>output <code>sudo service supervisor status</code></p>
  
  <pre><code>Jun 18 22:02:39 ip-172-31-3-59 systemd[1]: Started Supervisor process control system for UNIX.
  Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,828 CRIT Supervisor running as root (no user in config file)
  Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,829 WARN Included extra file "/etc/supervisor/conf.d/app_name.conf" Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 INFO RPC interface 'supervisor' initialized
  Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 CRIT Server 'unix_http_server' running without any HTTP authenticatJun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 INFO supervisord started with pid 19562
  Jun 18 22:02:40 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:40,837 INFO spawned: 'app_name' with pid 19569
  Jun 18 22:02:40 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:40,952 INFO exited: app_name(exit status 3; not expected)
  Jun 18 22:02:41 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:41,955 INFO spawned: 'app_name' with pid 19574
  Jun 18 22:02:42 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:42,069 INFO exited: app_name(exit status 3; not expected)
  </code></pre>
  
  <p>output from <code>app_name.err.log</code>. Although I set <code>PYTHONPATH</code> </p>
  
  <pre><code>  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
      return util.import_app(self.app_uri)
    File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 350, in import_app
      __import__(module)
    File "/home/ubuntu/FIFA_Captcha/app.py", line 2, in &lt;module&gt;
      from flask import Flask, render_template, request
  ImportError: No module named flask
  [2018-06-18 22:09:34 +0000] [19681] [INFO] Worker exiting (pid: 19681)
  [2018-06-18 22:09:34 +0000] [19677] [INFO] Shutting down: Master
  [2018-06-18 22:09:34 +0000] [19677] [INFO] Reason: Worker failed to boot.
  </code></pre>