3
votes

This is my first time using postgresql. I have checked and the server definitely seems to be running but I am getting this error when I start foreman

[...]postgresql_adapter.rb:1206:in `initialize': could not connect to server: No such file or directory (PG::Error)

Any ideas what's going wrong?

Thanks

UPDATE:

I opened pgAdmin and the db is set to listen on port 8000 instead of 5432 (which seems to be what rails wants). I have tried creating a new connection and setting it to 5432 but I get this error:

Server doesn't listen

The server doesn't accept connections: the connection library reports

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?
2

2 Answers

1
votes

I got Foreman to work again by modifying my database.yml file. I had to change the port to 8000 (which postgres was listening on).

0
votes

Changing the port did not work for me. I installed postgres on Mac using the Postgres.app

I had to update the Rails DB config (database.yml) to add the host field and set it to localhost and dropped the username and password fields

development:
  adapter: postgresql
  encoding: unicode
  database: project_development
  host: localhost
  pool: 5

After fixing that the error was about the database that I was connecting to not existing. To fix that, connect to postgres using psql and create the database

CREATE DATABASE project_development;

Replace the DB name with the right one for your case.

Also Postgres.app docs have additional info for configuring in other environments http://postgresapp.com/documentation#toc_3