title: Django + Psycopg2: InterfaceError: only protocol 3 supported
body: <p>When loading pages in my Django + Postgresql setup I occasionally get this error but not all the time:</p>
  <h1>psycopg2 in connect</h1>
  <h1>InterfaceError: only protocol 3 supported</h1>
  <pre><code>psycopg2/__init__.py ? in connect
  
          raise TypeError('missing dsn and no parameters')
      else:
          dsn = &quot; &quot;.join([&quot;%s=%s&quot; % (k, _param_escape(str(v)))
              for (k, v) in items])
  conn = _connect(dsn, connection_factory=connection_factory, async=async)
  if cursor_factory is not None:
      conn.cursor_factory = cursor_factory
  return conn
  </code></pre>
  <p>I have absolutely no idea what could be causing this.</p>
  <p>My production.py settings file:</p>
  <pre><code>    DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
              'NAME': 'mydbname',                      # Or path to database file if using sqlite3.
              # The following settings are not used with sqlite3:
              'USER': 'myuser',
              'PASSWORD': 'mypassword',
              'HOST': 'localhost',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
              'PORT': '',                      # Set to empty string for default.
          }
      }
  </code></pre>