1

Just started a new app with

rails <appname> new -d postgresql

I recently installed Postgres, and this is my first time trying to use it with an app. I generated a whole bunch of models, then ran rake db:migrate and got the following error:

rake aborted!
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Does this mean that I installed Postgres incorrectly? Any idea what I should fix? Or does the problem have to do with trying to migrate several models at once? Sorry if this is a dumb question. I'm new to both Rails and postgres.

----- MY DATABASE.YML -----

development:
  adapter: postgresql
  encoding: unicode
  database: <appname>_development
  pool: 5
  username: <appname>
  password:

  # Connect on a TCP socket. Omitted by default since the client uses a
  # domain socket that doesn't need configuration. Windows does not have
  # domain sockets, so uncomment these lines.
  #host: localhost
  #port: 5432

  # Schema search path. The server defaults to $user,public
  #schema_search_path: myapp,sharedapp,public

  # Minimum log levels, in increasing order:
  #   debug5, debug4, debug3, debug2, debug1,
  #   log, notice, warning, error, fatal, and panic
  # The server defaults to notice.
  #min_messages: warning

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: postgresql
  encoding: unicode
  database: <appname>_test
  pool: 5
  username: <appname>
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: <appname>_production
  pool: 5
  username: <appname>
  password:

--- Executed initdb /usr/local/var/postgres -E utf8 ---

Got the following:

initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "sashafklein".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default text search configuration will be set to "english".

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".

1 Answer 1

2

Did you create a config/database.yml?

This basically holds the connection information for Postgres

looks something like this

development:
  adapter: postgresql
  encoding: unicode
  database: <appname>_development
  pool: 5
  username: <username>
  password: <password>
Sign up to request clarification or add additional context in comments.

8 Comments

Yup. Was auto-created when I did Rails New. I'll post it above.
Try installing Pgadmin or running this to see if it's actually running /etc/init.d/postgresql status
Tried initdb /usr/local/var/postgres -E utf8, because I didn't know what you meant by running the above, and I figured re-initializing it would maybe make it run or tell me if it wasn't. Posted terminal response above.
Shoot. I also tried "pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start" to get the server starting and it didn't work. (I got that from the installation instructions).
Well that's about the end of my ability to admin postgres...how did you install it/what OS?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.