Whitelist allowed hosts for Heroku postgres? - postgresql

I have a heroku app running with the postgres addon. I was wondering if it's possible to whitelist the allowed hosts. Normally this is done by editing the pg_hba.conf file, but that's not possible on heroku.

It's not possible - Heroku don't provide access to that. They use highly complex and randomly generated username/passwords as you can see in your heroku config output but permit access from any host.

Related

In PostgreSQL, how to accept *any* password for the user "postgres"?

I'm working on many projects simultaneously, and some have some passwords defined as default, which can vary along projects. I've got postgresql installed on my (Ubuntu) laptop and of course I'm only using it locally for devving.
I know it's horribly insecure, but I don't expose postgres remotely. So to make things easier I would like the postgresql server to accept ANY password it is given for the postgres user. Is there any way that I could do this?
Set trust for all you local connections in pg_hba.conf like e.g
local all all trust
After editing, restart the postgresql service.

How do I connect to the Divio postgres database with local PgAdmin?

I am trying to connect with PgAdmin to the local Divio database in the container but PgAdmin 4 will not let me connect without a password. The Divio Postgres database seems to come without a password.
Has anyone got round this?
You don't need a password.
See Interact with the local database from your host environment in the official documentation.
The key things are:
expose the database’s port by editing the docker-compose.yml file
use the correct credentials
Both steps are described in more detail in the documentation. I haven't given more specific details here such as port numbers in case those details ever change in the future.

How do I view a PostgreSQL database on heroku with a GUI?

I have a rails app on heroku that is using a Postgre database. My database has > 40 tables and > 10,000 rows. I would like to delete a lot of data, but it would be much easier if I was able to view and interact with it in a GUI table. I can access my data in rails console, but it's taking too long.
pgweb is a great cross-platform GUI, and it's easy to connect to your Heroku Postgres when launching from the command line.
I installed via Homebrew on a Mac (brew install pgweb), but instructions for other platforms are listed on the site. Here's how I launch pgweb connected to a Heroku Postgres DB:
heroku config:get DATABASE_URL | xargs pgweb --url
And if you want to connect to your localhost:
pgweb --host localhost
I'm a little late here, but this may help someone else who stumbles across this thread...
If you go to your Heroku app's dashboard (through the website) > settings > "Reveal Config Vars" > DATABASE_URL, and paste that URL into the browser.
I use TablePlus for database management, when I paste the link into the browser it asks if it can open TablePlus and then I can edit my production database in real time just like I would in development.
I'm not sure what pasting the URL into the browser will do if you don't have TablePlus. I assume it will request to open any other SQL management app you might have.
As slumdog wrote in the comment to your question, you can use pgAdmin, which comes with your local Postgres installation.
This article explains how to connect your remote heroku db with pgAdmin, using heroku credentials: https://medium.com/#vapurrmaid/getting-started-with-heroku-postgres-and-pgadmin-run-on-part-2-90d9499ed8fb
From the article:
"pgAdmin is a GUI for postgresql databases that can be used to access and modify databases that not only exist locally, but also remotely. For a fresh install of pgAdmin, the dashboard likely contains only one server. This is your local server...
We have to configure a new remote server with its credentials.
right click server(s) > create > server …
Fill out the following:
Name: This is solely for you. Name it whatever you want, I chose ‘Heroku-Run — On’
Under the connection tab: hostname/address. If you go back to your datastores ‘reveal credentials’, this is the host credential. It should look like --**...amazonaws.com
Keep the port at 5432, unless your credentials list otherwise
Maintenance database — this is the database field in the credentials
Username — this is the user field in the credentials
Password — the password field in the credentials. I highly advise checking save password so that you don’t have to copypasta this every time you want to connect.
In the SSL tab, mark SSL mode as require
At this point, if we were to hit ‘save’ (please don’t), something very strange would happen. You’d see hundreds if not thousands of databases appear in pgAdmin. This has to do with how Heroku configures their servers. You’ll still only have access to your specific database, not those of others. In order to avoid parsing so many databases, we have to white list only those databases we care about.
go to the Advanced tab and under db restriction copy the database name (it’s the same value as the Maintenance database field filled earlier)."
Article contains other usefull guidelines and screenshots.
Try GUI of DBWeaver.
https://dbeaver.io/
Download it, after that you can connect your heroku postgres using Database Credentials data.
You can use Heroku's hosted DB viewer on the Overview pane of your dashboard:
Create and click the Dataclip:
Dataclip GUI is fairly easy to use, we can type and customize SQL queries at the top etc.

Heroku Postgres configure data center location

My understanding is that Heroku Postgres runs on top of AWS. Is it possible to configure which datacenter your database is running in? I'm also wondering if the database files are stored on an encrypted filesystem.
Yes, Heroku runs on AWS. But you are not able to specify which datacenter to run your database. For encryption look at http://www.postgresql.org/docs/current/static/pgcrypto.html.
Heroku runs out of Amazon US-East - once you've add a postgres db to your app heroku config will give you the database connection URL which you would be able to tracert on to see where it is

Automticaly setup add-on Heroku-Postgresql with one command

I want use PostgreSQL 9 in my app and to host on Heroku. By default heroku use Postgres 8.3.
To use Postgres 9, I need to install add-on heroku-postgres(https://addons.heroku.com/heroku-postgresql). In the documentation I found several steps to use Postgresql 9. It is simple, but I need to automatize and simplify all deploy steps.
Questions, I need at least one answer from these questions:
Is it possible by default use Postgresql 9 in Heroku without any add-on?
Is it possible to setup custom database urls names when I add the add-on like heroku addons:add heroku-postgresql:dev CUSTOME_HEROKU_DATABASE_URL_NAME?
Is it possible to use last database url in promote, e.g. heroku pg:promote HEROKU_POSTGRESQL_LAST?
Is it possible to promote database on adding add-on e.g.:heroku addons:add heroku-postgresql:dev --promote?
I don't want to use tools like grep or sed. This solution I built already.
PostgreSQL 9 is the default on Heroku now.
When you create a new Heroku database, it will always auto-generate a name for you (a color), you cannot change this.
There is no way to promote a new database to default without using grep / sed / customizations.
Is it possible by default use Postgresql 9 in Heroku without any add-on?
The dev plan will be the default on heroku. If you want it to be the default for you now, you can by adding this feature flag:
heroku labs:enable default-heroku-postgresql-dev
Is it possible to setup custom database urls names when I add the add-on like heroku addons:add heroku-postgresql:dev CUSTOME_HEROKU_DATABASE_URL_NAME?
No, not yet.
Is it possible to use last database url in promote, e.g. heroku pg:promote HEROKU_POSTGRESQL_LAST?
No, but if you have that flag set up, when you push code for the first time it will provision a dev database for you and it will have been promoted.
Is it possible to promote database on adding add-on e.g.:heroku addons:add heroku-postgresql:dev --promote?
No, but interesting idea.