title: How to use Flask/Peewee with Heroku?
body: <p>I am attempting to deploy a <a href="http://flask.pocoo.org/" rel="noreferrer">Flask</a> app to <a href="http://www.heroku.com/" rel="noreferrer">Heroku</a>.  I'm using <a href="http://peewee.readthedocs.org/en/latest/" rel="noreferrer">Peewee</a> as an ORM for a Postgres database.  When I follow the <a href="https://devcenter.heroku.com/articles/python" rel="noreferrer">standard Heroku steps to deploying Flask</a>, the web process crashes after I enter <code>heroku ps:scale web=1</code>.  Here's what the logs say:</p>
  
  <pre><code>Starting process with command `python app.py`
  /app/.heroku/venv/lib/python2.7/site-packages/peewee.py:2434: UserWarning: Table for &lt;class 'flask_peewee.auth.User'&gt; ("user") is reserved, please override using Meta.db_table
  cls, _meta.db_table,
  Traceback (most recent call last):
  File "app.py", line 167, in &lt;module&gt;
  auth.User.create_table(fail_silently=True)
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 2518, in create_table if fail_silently and cls.table_exists():
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 2514, in table_exists return cls._meta.db_table in cls._meta.database.get_tables()
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 507, in get_tables ORDER BY c.relname""")
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 313, in execute cursor = self.get_cursor()
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 310, in get_cursor return self.get_conn().cursor()
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 306, in get_conn self.connect()
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 296, in connect self.__local.conn = self.adapter.connect(self.
  database, **self.connect_kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/peewee.py", line 199, in connect return psycopg2.connect(database=database, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 179, in connect connection_factory=connection_factory, async=async)
  psycopg2.OperationalError: could not connect to server: No such file or directory
  Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  Process exited with status 1
  State changed from starting to crashed
  </code></pre>
  
  <p>I've tried a bunch of different things to get Heroku to allow my app to talk to a Postgres db, but haven't had any luck.  Is there an easy way to do this?  What do I need to do to configure Flask/Peewee so that I can use a db on Heroku?</p>