0

i'm new to ruby on rails, i'm trying to run an app with postgres database, but it didn't work, i have tried to search lots of information, but i wasn't useful, Someone posted the exactly same question here Problems with rails server , I tried to use command rails new blog it created an app with sqlite3 database, it works fine, but i created app with command rails new myapp --database=postgresql after that i visit localhost page, it ocurred the exactly same error

could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Can anyone help? it would be very much appreciated.

database.yml file information:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: myapp_development

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  database: myapp_production
  username: myapp
  password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
Community
  • 1
  • 1
gqli
  • 985
  • 3
  • 11
  • 34
  • Can you include your config/database.yml file in your question please? – Luca B. Aug 21 '14 at 07:51
  • Hello, i have just included the yml file, Thank you very much – gqli Aug 21 '14 at 07:58
  • please include pg_hba.conf – tty6 Aug 21 '14 at 08:00
  • Did you check your db is actually running on it's default port? Also what environment you're currently running the app in? – Luca B. Aug 21 '14 at 08:00
  • Hello, i'm a beginner,I couldn't find pg_hba.conf. I am running it on my local MAC OS 10.9.4 ,Thank you guys. – gqli Aug 21 '14 at 08:08
  • @Snailwalker http://stackoverflow.com/questions/14025972/postgresql-how-to-find-pg-hba-conf-file-using-mac-os-x – tty6 Aug 21 '14 at 08:14
  • I followed that link , it returned only:" Snailwalkers-MacBook-Pro:~ snailwalker$ ps aux | grep postgres snailwalker 452 0.0 0.0 2432784 488 s000 R+ 3:20PM 0:00.00 grep postgres " But no format ... -D .... E.G: as they mentioned. – gqli Aug 21 '14 at 08:27
  • Have you actually installed postgres? – Matt Aug 21 '14 at 08:39
  • i checked with brew list command, i think i have installed apple-gcc42 automake gcc46 gmp4 libiconv libmpc08 libxml2 libyaml openssl pkg-config ppl011 autoconf cloog-ppl015 git libgpg-error libksba libtool libxslt mpfr2 ossp-uuid postgresql readline – gqli Aug 21 '14 at 08:40
  • Hello guys, After i reinstall home brew, use brew doctor command, and follow the instruction and reinstall postgres after that. i solved the problem. haha i think i messed up the evrionment . This is the link http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/ – gqli Aug 21 '14 at 11:59

1 Answers1

0

Delete this file:

/usr/local/var/postgres/postmaster.pid

Original Answer: psql: could not connect to server: No such file or directory (Mac OS X)

Community
  • 1
  • 1
Amr Arafat
  • 469
  • 3
  • 8
  • Thanks for Answering this question, i think your comment inspired my to solve the issue, It's related. Here is the link i followed up with, i reinstalled home-brew and Postges http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/ – gqli Aug 21 '14 at 12:02