How to copy PostgreSQL database to server from local computer - postgresql

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!

Related

Unable to connect with PostgreSQL with command line psql: error: connection to server at "localhost" (::1), port 5432 failed

I have been trying to connect with the newly created PostgreSQL database. But in the command line, it is showing
psql: error: connection to server at "localhost" (::1), port 5432 failed, FATAL: password authentication failed for user <user>
I am entering the right password but still having the issue
Solved this issue:
In my case entered username was incorrect.
I checked installation_summary.txt file to know the username.

Connection to Postgres in Windows powershell

When I try to connect to postgres in windows powersehll I get the error:
error: connection to server at "localhost" (::1), port 5432 failed:
FATAL: password authentication failed for user "user"
But I can connect correctly through wsl (Windows Subsystem for Linux).
BTW I use the following command
$ psql -U user
and postgres is installed in container with Docker.
What can be wrong?

Postgresql not starting even after editing rc file

I receive the following error when I try to start postgresql aka psql in Slackware Linux:
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
I am trying to start it and changed the field in pg_hba.conf to trust from md5.
At some point it was asking for a password.
I get the following when I try to start the server:
bash-5.1# postgres -D /pgsql/data
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
bash-5.1# postgres -D /pgsql/data >logfile 2>&1 &
[1] 8310

PSQL: SSL error: unknown protocol

all. I have a new Ubuntu 17.04 server setup. I can access it through ssh successfully. Also, I have a postgresql database installed. It is already configured to accept remote connections through the following configurations:
pg_hba.conf
host all all 0.0.0.0/0 md5
postgresql.conf
listen_addresses = '*'
But when I try to access the database from my computer, I get the following error:
psql -h [SERVER_IP] -d db_production -U dbuser
psql: SSL error: unknown protocol
expected authentication request from server, but received S
I also have a docker container running inside the server. If I access it through /bin/bash and also try to connect with the server db, I get this error:
psql -h [SERVER_IP] -d db_production -U dbuser
psql: could not connect to server: Connection refused
Is the server running on host "[SERVER_IP]" and accepting
TCP/IP connections on port 5432?
The port 5432 is opened and the firewall is disabled. Does anybody have gone through that?
First, do you use the local server host when you're connected into the docker? The server IP, in that case, should be localhost or 127.0.0.1.
Try to use the complete DB URL:
psql postgres://dbuser:dbPass#SERVER_IP:5432/dbname?sslmode=prefer

Heroku PostgreSQL / NodeJS connection permission denied?

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