I recently uninstalled postgres (not sure if I did it properly. I used homebrew to uninstall it and also manually deleted whatever showed up on locate psql in my Terminal. Then I installed postgres.app and tried running it. However it prompts for a password (that I don't remember or don't even know exists or not) even though I went to the pg_hba.conf file I found in
Edmunds-MacBook-Pro:~ edmundmai$ locate pg_hba
/usr/share/postgresql/pg_hba.conf
and changed it to trust for everything:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Am I missing something? I can't get psql to run because it prompts for a password. I'm willing to uninstall it if that fixes it.
Try restarting the server. Just editing pg_hba.conf isn't enough on its own.
On Ubuntu with postgres 9.1 the following worked for me
sudo /etc/init.d/postgresql restart
For more information see the documentation on the Ubuntu help pages
Related
So I'm trying to start working on an existing RubyRails app, I've got RVM, Rails and PostgreSQL set up. I've tested rails server on a test app I made, I can connect to localhost:3000 just fine. When I copy over the existing app I'm trying to work on, cd to it and run rails server, localhost:3000 gives me
PG::ConnectionBad
fe_sendauth: no password supplied
I've looked for a few hours across Google and SO and can't find a proper solution. What I tried after a lot of reading was changing my pg_hba.conf file for postgres to have the following settings:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres md5
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
I saved these changes and restarted the terminal (to reload these changes), and I am getting the same error on localhost:3000, the PG:ConnectionBad error. Could anyone lend a hand? This is so frustrating.
In case it helps, I'm using Ruby 2.1.1 and Rails 4.1.0 and PostgreSQL 9.3 Thank you!
Restarting the terminal is not enough. You can restart Postgres with
service postgresql restart
Looks like there is no password specified for the database:
fe_sendauth: no password supplied
You can see how you specify username and password for your database here:
http://guides.rubyonrails.org/configuring.html#configuring-a-database
Developing RoR app on Windows using RubyMine, trying to connect to Postgres database hosted on Heroku server. No Postgres installed locally. Getting "java.sql.SQLException: FATAL: no pg_hba.conf entry for host..." What to do, what to do?
This is due to Heroku databases needing additional SSL configuration.
You need to enable SSL in your jdbc string by appending:
?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
For details see Heroku's help document.
It looks like this is a RubyMine issue. RubyMine will convert the hostname to an IP address and pg_hba.conf includes the hostname but not the IP address hence the error. It works fine from the command line (e.g. rails s).
Getting:
An error has occurred:
Error connecting to the server: fe_sendauth: no password supplied
Settings in database.yml are the same as the app setup on other machines.
How can I set things up so that I don't need a password hardcoded?
I can view the db ok using PgAdmin-III.
I'd rather not have the password in database.yml as other machines using this app don't have/need it, so it seems likely to be something about my Pg install.
You need to change your change your pg_hba.conf. Here's an example of mine:
pg_hba.conf:
TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 trust
host all PC 127.0.0.1/32 trust
host all all ::1/128 trust
Note that trust means that anyone on address (in this case localhost) can connect as the listed user (or in this case any user of their choice). This is really only suitable for development configurations with unimportant data. Do not use this in production.
#rodrigo-zurek was spot on; you have to change the pg_hba.conf. Just want to add this answer for the OSX users because the pg_hba.conf is located in a different place by default.
sudo su - postgres
vim /Library/PostgreSQL/<YOUR_VERSION>/data/pg_hba.conf
The default will have md5 in the column METHOD, but replace all of those with trust:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Then, open up pgAdmin III inside your Applications/PostgreSQL 9.X, right click the database (e.g. PostgreSQL 9.4 (localhost)), and click Reload Configuration. After this, I was able to rake db:create.
No password supplied means you have set it up to require password authentication and no password is being supplied. Here is documentation for 9.0: http://www.postgresql.org/docs/9.0/static/auth-methods.html
Keep in mind that local auth was changed from "ident" to "peer" in 9.1 to avoid confusion. See the 9.1 docs at http://www.postgresql.org/docs/9.1/static/auth-methods.html
Also keep in mind that this is an ordered rule set with first match governing. Furthermore local and localhost are different. Local is for local UNIX domain socket connections, while host localhost would be for network connections to localhost. So it sounds like you have some troubleshooting to do but hopefully the docs should help.
#appveyor.yml
services: postgresql
test_script:
- SET PGUSER=postgres
- SET PGPASSWORD=Password12!
- PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
I'm on osx and I have problems creation of user postgresql.
when I write the command:
createuser myapp -s
I get the following error:
could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I do not know if it's just PATH directory problem.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
I installed postgresql with this solution : http://tammersaleh.com/posts/installing-postgresql-for-rails-3-1-on-lion
thanks for your help and sorry for my bad english.
Are you sure the postgres server is running? (Use "ps ax | grep postgres"). Has it opened a TCP port (per default 5432)? Is this unix socket "/var/pgsql_socket/.s.PGSQL.5432" available and do you have the permissions to read/write it?
Furthermore, you may want to check the pg_hba.conf file where the permissions on the postgres server itself are configured.
I just updated my gems. And now I have problems connecting to my postgresql database. I get the error:
PGError
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"?
I tried uninstalling the gem and reinstalling, I also tried to change the paths file and put '/usr/local/bin/' on top. I tried some of the things from post:
Repairing Postgresql after upgrading to OSX 10.7 Lion
This app worked fine before updating my gems, other apps still connect just fine, to the same server. I have the same settings in my database.yml file.. what could be wrong?
The error comes from the PostgreSQL server and I have seen it many times. It tells you that you are trying to connect via Unix domain socket (and not via TCP/IP!) to a server that is running locally and listening at port 5432. But no server can be found that would accept connections like that.
You did not mention where the PostgreSQL server resides - I assume you actually mean to connect to a database server on your local machine.
Check your setup, especially your pg_hba.conf file. You need a line like:
local mydb myuser md5
or
local all all peer
or some other connection method that includes your user and database.
These would not help in your case:
host ...
or
hostssl ...
They concern TCP/IP connections, not local connections via UNIX domain socket. When you connect to localhost you actually use TCP/IP via local loop and these settings apply.
Remember to reload after you edit pg_hba.conf. I quote the manual at the linked site:
If you edit the file on an active system, you will need to signal the
postmaster (using pg_ctl reload or kill -HUP) to make it re-read the
file.