title: django & postgresql - could not connect to server: Connection refused
body: <p>I have an os x server running django 1.6 and postgresql 9.</p>
  
  <p>I have just noticed that if I logout of the machine I can no longer connect to my app from another machine.</p>
  
  <p>The error is:</p>
  
  <pre><code>could not connect to server: Connection refused
      Is the server running on host "localhost" (::1) and accepting
      TCP/IP connections on port 5432?
  could not connect to server: Connection refused
      Is the server running on host "localhost" (127.0.0.1) and accepting
      TCP/IP connections on port 5432?
  could not connect to server: Connection refused
      Is the server running on host "localhost" (fe80::1) and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  
  <p>I have had a look around for a solution but I can't seem to get it to work.</p>
  
  <p>My django settings are:</p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'mydb',
          'USER': 'myuser',
          'PASSWORD': 'mypw',
          'HOST': 'localhost',
          'PORT': '5432',
      }
  }
  </code></pre>
  
  <p>And as I say if I log in to the server with my server user i can then immediately access my web app from another machine. I hope that makes sense. It's as if postgresql runs when my user logs in.</p>
  
  <p>I am assuming that postgresql runs as root / in the background despite whatever user is logged in.</p>
  
  <p>Any ideas?</p>