Heroku PostgreSQL / NodeJS connection permission denied? - postgresql

So I would like to import a local dump to my heroku postgresql db, however, any command I run I just get ...
psql: could not connect to server: Permission denied (0x0000271D/10013)
Is the server running on host "ec2-23-23-192-242.compute-1.amazonaws.com" (23.23.192.242) and accepting
TCP/IP connections on port 5432?
This is using the credentials set by the heroku pg add-on, and I have triple checked them to ensure they are correct. Does anyone know why the hell it keeps giving me Permission denied? I can reset the db from the heroku CLI but I can't perform any other action... weird.

you are behind some strict firewall or just isolated from internet, I assume. Look what I get:
-bash-4.2$ psql -h ec2-23-23-192-242.compute-1.amazonaws.com
Password:
psql: FATAL: password authentication failed for user "postgres"
FATAL: no pg_hba.conf entry for host "xx.xx.xx.xx", user "postgres", database "postgres", SSL off

Related

psql: ERROR: no pg_hba.conf entry for host "x.x.x.x", user "cp", database "abcd", SSL off PGBOUNCER Issue

I am trying to connect to database using pgbouncer. Our db is POSTGRESQL which run on the managed service given by AZURE. Now after configuring Pgbouncer.ini file on Ubuntu 18.04 LTS I am facing the following issue: Whenever I try connecting using localhost :
psql -U user -h localhost -p 6432 abcd
It'll give the output as
psql: ERROR: no pg_hba.conf entry for host "x,x,x,xx", user "username", database "dbname", SSL off
I am quite intrigued I haven't given such config they why still pgbouncer is looking for pg_hba.conf file.

How to copy PostgreSQL database to server from local computer

I am trying to copy PostgreSQL database from my computer to Ubuntu 20.04 server. Also, a python script with a database is running on the server using docker-compose. I enter this command on my computer:
pg_dump -C -h localhost -U steamtrader_pguser steamtrader | psql -h *server IP* -U steamtrader_pguser steamtrader
but I get errors:
psql: error: FATAL: password authentication failed for user "steamtrader_pguser"
pg_dump: error: could not write to output file: Broken pipe
The PostgreSQL account on the server and on my computer have the same username, password and database name. But when I enter the password, I get an error that it is incorrect. I also get errors on the server side:
FATAL: password authentication failed for user "steamtrader_pguser"
DETAIL: Password does not match for user "steamtrader_pguser"
Connection matched pg_hba.conf line 94: "host all all 0.0.0.0/0 md5"
I enter the command on my computer while the database script is running on the server. If I stop the script but leave the server running, I get the following error when I issue the command:
Password: psql: error: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "18.188.219.232" and accepting
TCP/IP connections on port 5432?
I'm new to this topic, so I would really appreciate your help!

Connection to remote machine postgresql database

I am trying to connect to a VM ubuntu from my local computer. On the VM I have created a postgresql database. Then I followed all steps that I could find on several tutorial when it comes to allow access for remote connexion to the db:
add host all all 0.0.0.0/0 trust to the pg_hba.conf file
add listen_addresses = '*' to the postgresql.conf file
remove the firewall by executing sudo ufw allow 5432/tcp
restart postresql by executing sudo systemctl restart postgresql
By using the command psql and then \c gives You are now connected to database "postgres" as user "postgres".
I then create a password by executing ALTER USER postgres WITH PASSWORD 'password';
Then I use postico to connect locally. I want to connect with this same default superuser postgres for testing. I use the VM ip address as host, db name is postgres user postgres, password is password and port 5432 as mentioned above.
After trying to connect for a while with the message opening connection to server, the result is:
could not connect to server: Operation timed out
Is the server running on host "***.**.**.***" and accepting
TCP/IP connections on port 5432?
Any help please? I did all steps I could find on many tutorials but still failing to connect.

PostgreSQL: FATAL: password authentication failed for user "postgres"

I have a ThingsBoard Professional Edition setup using AWS EC2 instance. The database is PostgreSQL-12. I tend to get the following error: FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" when trying to log into the remote database server on pgAdmin4.
Here is a screenshot of the error shown when attempting to log in to server created on pgAdmin4.
Here is how I configured the remote database server (where Host name/address is the Public IPv4 of my EC2 instance).
In postgresql.conf, I have replaced the line listen_address='127.0.0.1' with listen_addresses='*'.
In pg_hba.conf, I added host all all 0.0.0.0/0 md5.
Here is a screenshot of my pg_hba.conf file:
I have also set the password for the user 'postgres' using the psql command #\password.
Here is what is shown in thingboard.log when I run the command:
cat /var/log/thingsboard/thingsboard.log | grep ERROR
Partial screenshot of /var/log/postgresql/postgresql-12-main.log shows the following:
I constantly have to use #ALTER USER postgres PASSWORD ‘<password>’; to be able to overcome this error but the error tends to return when I restart my local Windows machine.
That must be done by some software other than PostgreSQL.
Configure logging by setting log_statement = 'ddl' in postgresql.conf and restarting the database. Then you can more easily figure out when and by which software your password gets changed.
Additionally, configure pg_hba.conf to not allow passwordless connections from anywhere, then change the password. You may see some component start to complain - that component may be at fault.

Password Error when logging into POSTGRES on my MAC

I am having an issue that has been bothering me for some time now. It is with postgres on my mac. I set a password for postgres and I can not remember it for some reason. I have looked up and attempted several different methods for trying to reset the password but none of them are working and I need it fixed as soon as possible.
Here is what my pg_hba.conf file
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
I reset the local all all trust and then restarted my postgres server running
brew services restart postgres
and when i go to try and open postgres on my terminal I get the same password issue:
omars-MacBook-Pro:postgres omarjandali$ psql -U postgres -W -h localhost
Password:
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres"
or
omars-MacBook-Pro:~ omarjandali$ psql -h 127.0.0.1 -U postgres
Password for user postgres:
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres"`
You only configured "local" connections which are using Unix domain sockets. But your psql command line tries to establish a TCP connection (-h ...), which is not configured in your pg_hba.conf.
You need to use host instead of localin pg_hba.conf to allow trusted, non-password connections through TCP.
But that is a really, really bad idea, because that means that as soon as your Mac is visible on the internet, everybody can connect to your Postgres instance and hack it. This isn't a theoretical threat - there have been numerous posts on this site regarding that.
If you want to allow connections without passwords, at least only allow them from "localhost", not from the outside:
# TYPE DATABASE USER ADDRESS METHOD
host all all samehost trust