Using Postgres 9.2.2, I keep getting this error when I try to start up rails server or run psql
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"?
This command, when run:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
says server starting, but when I go to check processes, no postgres process is running
My paths are correct
$ which psql
/usr/local/bin/psql
$ which pg_ctl
/usr/local/bin/pg_ctl
If I run this command:
initdb /usr/local/var/postgres -E utf8
It will connect to the socket.... but it also requires me to remove my databases, which is pretty frustrating. This seems happens every time I restart.
Using
Postgres 9.2.2
Brew
OSX Mountain Lion
I found similar threads on stack overflow but none of the solutions seemed to work.
Screw it. I just installed Postgres.app by Heroku. No more messy issues.
I saw this issue arise again once more with someone who actually had Postgres.app installed. Though, it's unclear why his threw this error because I've never seen it before with Postgres.app.
The solution was changing the database.yml file from:
development: &default
adapter: postgresql
database: myapp_development
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
test:
<<: *default
database: myapp_test
To:
development: &default
adapter: postgresql
database: myapp_development
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000
host: localhost
test:
<<: *default
database: myapp_test
Only difference is the "host" line
Related
My heroku rails app has following database settings for production
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
production:
<<: *default
database: db/production.sqlite3
As you can see there is no password in the database. I downloaded the database with the commands
heroku pg:backups:capture
heroku pg:backups:download
Now I want to restore the database, which command should I run to restore the database?
This is what worked for me
pg_restore -d myapp_development -U rails_dev -C latest.dump
Here, my local development database myapp_development, local database username rails_dev and latest.dump is the backup database file downloaded from server. Command above ask for a password which should be the password associated with user rails_dev.
I am getting the following error when I run RAILS_ENV=production bundle exec rails s
`bind': Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)
I have tried some of the other post, from where I found the following command rails s -p 3001 This works for localhost:3001 but when I push to heroku I get the following error when I go to my url. I am guessing there's maybe an issue with my database.yml file since it has given me some issues.
We're sorry, but something went wrong.
rails -v Rails 4.2.1
ruby -v ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin15]
database.yml
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: vlog_development
test:
<<: *default
database: vlog_test
production:
<<: *default
database: vlog_production
username:
password:
This is because of your default 3000 port is busy.Use command "ps" on terminal
PID TTY TIME CMD
4662 pts/5 00:00:00 bash
4975 pts/5 00:00:03 ruby
4982 pts/5 00:00:00 ps
Then kill process by command on terminal sudo kill -9 PID. Then start your server again.
I want to connect to the heroku pg:psql but it's not working anymore. Don't know what to do after searching the web and also Stackoverflow for hours.
The command heroku pg:psql gives me this error:
The local psql command could not be located
For help installing psql, see article about local-postgres
Working on a Mac with OS X (Version 10.9.1), Ruby 1.9.3. and Rails 4.0.1.
My database.yml is as following:
development:
adapter: postgresql
encoding: unicode
database: outspotly_v1_development
pool: 5
username: fabianwydler
host: localhost
port: 5432
test:
adapter: postgresql
encoding: unicode
database: outspotly_v1_test
pool: 5
username: fabianwydler
host: localhost
port: 5432
production:
adapter: postgresql
encoding: unicode
database: outspotly_v1_production
pool: 5
username: fabianwydler
host:
port:
Is there, perhaps, something wrong with my $PATH?
heroku run rails db
Running `rails db` attached to terminal... up, run.3540
Couldn't find database client: psql. Check your $PATH and try again.
Fabians-MacBook-Pro:outspotly_v1 fabianwydler$ echo $PATH
/Users/fabianwydler/.rvm/gems/ruby-1.9.3-p194/bin:/Users/fabianwydler/.rvm/gems/ruby- 1.9.3-p194#global/bin:/Users/fabianwydler/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/fabianwydler/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
If the $PATH is wrong I don't know how to handle this because I'm not so familiar on Mac.
Thank you very much for your help.
Greetings, Fabian
You need to install a local copy of psql. By far the easiest way is to install homebrew and then postgresql:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install postgresql
I'm trying to deploy on heroku a simple blog I created with RoR for learning purposes and sqlite3 is not supported so I decided to migrate to PostgreSQL.
I changed my database.yml file
development:
adapter: postgresql
encoding: utf8
database: blog_development
pool: 5
username: user
password:
test:
adapter: postgresql
encoding: utf8
database: blog_test
pool: 5
username: user
password:
installed PostgreSQL using:
brew install postgresql
removed sqlite3 and added:
gem 'pg'
and ran bundle install
when I tried running:
rake db:create
i got:
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?
I tried fixing it with:
In Rails, Couldn't create database for {"adapter"=>"postgresql",
and:
http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
http://www.mozmorris.com/2011/11/15/configure-postgresql-to-accept-tcpip-connections.html
Addl. Info:
RoR: 4.0
Ruby: 2.0.0
psql: 9.3.1
pg: '0.17.0'
OS: OSX Mavericks
Make sure postgres is running
First Install postgres using homebrew(which you've already done)
brew install postgresql
Second: Create a new PostgreSQL database cluster
initdb /usr/local/var/postgres
Finally: Start postgresql
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Maybe the 'user' user doesn't exist.
On the command line, try this:
psql
psql=# create user name_here;
psql=# alter user name_here superuser;
psql=# \q
I am using ubuntu 12.04 and rails 3.2. I am creating a rails application in which I'm using PostgreSQL databse. I installed postgresql using the following command:
sudo apt-get install postgresql
for reference i checked out https://help.ubuntu.com/community/PostgreSQL. Later I created the user postgres and set the password postgres using the following command
sudo -u postgres psql postgres
\password postgres
Next I created the database using:
sudo -u postgres createdb mydb
I tried to connect with Postgresql with the username postgres and password postgres and got successfully connected with the following command:
psql -U postgres -h localhost
Password for user postgres:
psql (9.1.4)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
postgres=#
In my rails app my database.yml has the following code:
development:
adapter: postgresql
encoding: unicode
database: mydb_development
pool: 5
username: postgres
password: postgres
test:
adapter: postgresql
encoding: unicode
database: mydb_test
pool: 5
username: postgres
password: postgres
production:
adapter: postgresql
encoding: unicode
database: mydb_production
pool: 5
username: postgres
password: postgres
Now when I run the command rake db:migrate i get the following error:
rake aborted!
FATAL: Peer authentication failed for user "postgres"
I tried adding host: localhost to database.yml for each environment and i get the following error:
rake aborted!
couldn't parse YAML at line 28 column 0
The line 28 is
development:
adapter: postgresql
encoding: unicode
database: hackathonio_development
pool: 5
username: postgres
password: testing
host: localhost {This is line 28}
Please help me figure out a solution for this..
I think you may have 2 problems. First, the host not being set as Shreyas pointed out. But I believe the second problem is that when you set the hostname Rails is trying to connect to PostgreSQL via a tcp socket and not a local ruby socket. My guess is you need to modify your pg_hba.conf file to allow postgres to login via localhost. Below are a few SO questions with answers that may help.
Rails can't login to postgresql - PG::Error - password - Correct info
What's the difference between "local" and "localhost" connection types in pg_hba.conf?
Can't use postgres user in new database for rails 3 on ubuntu 10.04 server
Please add host to your yml as localhost
My recommendation:
Step 1
Create a new, different user by running
$ createuser <username>
on the command line. You'll be prompted for password, etc. (Examples/docs: http://www.postgresql.org/docs/8.1/static/app-createuser.html)
Step 2
Update database.yml with the new users's username/password. Forget the first user you created, at least for now.
Step 2
$ rake db:create
Step 3
$ rake db:migrate
I think those steps are more likely to work that what you're trying.