Postgres.app setup for heroku - postgresql

I'm trying to install Postgres.app on my mac (lion), and running into issues.
I'm trying to follow the instructions here: https://devcenter.heroku.com/articles/heroku-postgresql#local-setup.
So, as the first step I downloaded the app here: http://postgresapp.com/.
Next, I opened the documentation here:http://postgresapp.com/documentation.
When I run $ psql -h localhost, it asks for a password, and I have no idea what the password is supposed to be. Can somebody help with figuring out how to set Postgres.app as the default database for using Heroku?
Thanks.

You're probably using the psql that comes built-in to Mac OS X, thanks to Apple's incredibly frustrating decision to bundle an (old) PostgreSQL on the default port and with its tools on the default PATH.
Check psql --version to see what you're running.
Quite likely you need to set your PATH so it finds the psql from Postgres.app . Or you can check what port Postgres.app is running on and specify a port, though if you use an old psql with a new PostgreSQL then you'll have issues with backslash commands. This is explained just a few paragraphs down in the documentation you were reading.

Related

`heroku pg:psql` doesnt work but psql works

Note: I'm on windows.
After installing postgreSQL in my computer trying to use heroku pg:psql gives me this error:
--> Connecting to postgresql-defined-56809
! The local psql command could not be located. For help installing psql, see
! https://devcenter.heroku.com/articles/heroku-postgresql#local-setup
The psql command works and psql --version returns the same version that my database uses on heroku as returned by heroku pg:info.
I have followed the instructions in that link and it still doesn't work (well I did that from the beginning). I even restarted my computer but it still doesn't work.
Edit: found that psql runs in powershell but not in cmd
Okay so after trying to set up the PATH from cmd I think I messed something up and the heroku command didnt work anymore and I reinstalled heroku and now everything works fine. What a waste of time.

pg_hba.conf for Postgresql from Windows Anaconda

I've just installed Postgressql (9.5.4 vc14_0) and Psycopg2 (2.7.5 py36h74b6da3_0) and I'm trying to use them within my Anaconda environment on Windows 10.
Whenever I run psycopg2.connect("host=localhost user=postgres") in a python interpreter or just psql on the command line I get this error:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
I've looked at other Stackoverflow questions regarding this, some answers say to look into a pg_hba.conf file although I haven't be able to find any. Where can I find a pg_hba.conf file for my Postgresql in my Anaconda Environment for Windows? If I have to make one, what should go in it? I haven't seen another SO question that uses the same Postgresql-Anaconda-Windows setup that I'm using.
Also I've looked into services.msc but haven't seen a service regarding postgresql.
I just ran into this error as well. Similar to what you did, I followed the installation page, ran conda install -c anaconda postgresql and received the same error in your post.
I have used postgresql through direct installation before, in osx and as far as I can recall, you could just psql into the database once the installation is complete.
Maybe this isn't the case for anaconda installations. I overcame this by initializing a new database system in a new, empty folder. In my case, I created a new folder in "\AppData\Local\conda\"
-- Initialize the database system
pg_ctl init -D <path_to_your_database_system>
-- Start the database
C:/Users/kerwei/AppData/Local/Continuum/anaconda3/envs/py36/Library/bin/pg_ctl -D <path_to_your_database_system> -l logfile start
NOTE: After playing around with for awhile, I realized that once you exit the conda environment, the database instance gets terminated too - without properly shutting down. As I don't use it for production stuffs, it doesn't really bother me. However, further steps can be taken to include the database booting and shutting down during conda activate or conda deactivate to make it less cumbersome.

Cannot find PostgreSQL files, clusters, or service; what to do?

I am currently trying to install and setup PostreSQL on my computer (Debian 9) so I can use it as a local testing environment for Heroku. I have been having some problems. First, whenever I try to run psql (and similar commands), I get this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I have looked around on here for some fixes to this, such as this one, however I cannot find the postmaster.pid anywhere inside /usr. When looking for /var/run/postgresql, my search also turned up nothing.
Another promising answer was this one, however, I run pg_lsclusters, none appear. From a bit of searching, it says that this is probably due to initdb never being ran. I looked around for several ways to do this manually; none of them have worked or appear to exist on my system.
I have tried many of the "simple" things, such as sudo, sudo su postgres, removing and reinstalling the package and screaming at the computer.
What exactly is going on here? How do I fix it?
My OS (as mentioned before) is Debian 9, and the psql --version (which does work) is psql (PostgreSQL) 10.4 (Debian 10.4-2.pgdg90+1).

Error when opening pgAdmin 4 on mac

I have installed version 4-1.5, but when opening it, it always shows this error "The application server could not be contacted."
I removed the local directory hidden and resolved:
$ cd ~
$ rm -r .pgadmin/
Note: macOS Sierra (10.12.6) and pgAdmin 4-1.6. Also you are going to loose configuration data like database list tree, et al.
The Databases will remain intact since you are modifying/deleting PgAdmin related data not any of Postgresql itself.
I had the same issue, I fixed it by stopping the service in Postgres app, then start pgAdmin, and then start the Postgres service. I was able to connect it after that. Hope this help.
I had same error, but in my case I use wrong port number for the database
On my system Safari is the problem as it was default browser.
To fix, make Chrome your default browser and try relaunching pgadmin4
OR
Manually fix by
$ cat ~/.pgAdmin4.5704814747986328352.addr
http://127.0.0.1:62631/?key=0ec25e6a-dfe2-483e-9814-b315ea87c3cf
Paste what you get in Chrome

How should I fix this PostgreSQL installation?

I realized that PostgreSQL was already running on my laptop (Mac OS X) before I installed from the Postgres site. So when I used the installer, I got the PostgreSQL and logged in to the postgres user account that was created.
In the terminal I wrote
psql -U postgres
And provided my password. I got logged in but it said,
WARNING: psql version 9.0, server version 9.1.
Some psql features might not work.
How should I go about fixing this so that I can access the database properly without any issues?
The warning comes from psql, the PostgreSQL interactive terminal. Nothing bad will happen.
As you have two versions of PostgreSQL installed in parallel, you would need two versions of psql. Maybe you even have them on disk. But when you type the command psql, your system will default to one of those, not knowing beforehand which database server version you are going to connect to.
You can type the explicit path to the psql version you want. Find the full path of all variants with this shell command (works with Linux, not tested with Mac OS X):
which -a psql
If you did not also install the psql version 9.1 along with your PostgreSQL, you have to install it first, of course.
If you are not going to use PostgreSQL 9.0 any more, you can uninstall it to remove ambiguities.
In Debian you can also set the default of multiple alternatives with:
update-alternatives
But in Debian you also have a wrapper that calls the matching psql dynamically if you specify the database cluster like this:
psql --cluster 9.1/main
Not sure about Mac OS X.
You have installed postgresql-server 9.1 (server side) and postgres (client side 9.0). Maybe you have installed client 9.1 too, but it is not on the path, so you have to find it or if you have not it, then install it.