title: cannot connect to Postgres (pg) database from my Ruby Script using gem "pg"(This is not rails, just pure ruby)
body: <p>I downloaded the postgres.app for my Mac OSX machine. I have a rails app that has connected and used the postgres DB that came with the postgres app. </p>
  
  <p>Now I am writing a pure Ruby test script (Not Rails, pure Ruby, not even Active Record) to try to connect to the postgres database instance. These are the steps I followed to set this up </p>
  
  <pre><code> 1) ran this command on the terminal:
      gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
  
   2) Added this code to the test script:
  
     #!/usr/bin/env ruby
     #encoding: utf-8
     require "pg"
  
  
      @conn = PG.connect(
      :dbname =&gt; 'oData',
      :user =&gt; 'am',
      :password =&gt; '')
  
      @conn.exec("CREATE TABLE programs (id serial NOT NULL, name character varying(255);");
  </code></pre>
  
  <p>I got this from this <a href="http://marcclifton.wordpress.com/2012/11/12/an-example-of-using-postgresql-with-ruby/" rel="nofollow">link</a></p>
  
  <p>When I ran this script I get the following error:</p>
  
  <pre><code>   /Users/am/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/lib/pg.rb:38:in `initialize': could 
      not connect to server: No such file or directory (PG::ConnectionBad)
  Is the server running locally and accepting
  connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
  </code></pre>
  
  <p>My Debug efforts:</p>
  
  <pre><code>  My postgres.app is up and running. 
  
    I looked at the pg gem [documentation][2] and my syntax seemed OK.
  
    The location of my postgres DB is entered in my bash script like so
     PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
  </code></pre>
  
  <p>Not sure what to do next. Any help would be appreciated, Thanks.</p>