I installed Postgresql with scoop.
To start the installed PostgreSQL, I cd to C:\Users\my_user_name\scoop\apps\postgresql\current\bin directory and run postgres.exe what gives me the following output in the command prompt:
C:\Users\my_user_name>C:\Users\my_user_name\scoop\apps\postgresql\current\bin\postgres.exe
2022-09-30 12:50:05.195 GMT [17456] LOG: starting PostgreSQL 14.5, compiled by Visual C++ build 1914, 64-bit
2022-09-30 12:50:05.203 GMT [17456] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-09-30 12:50:05.203 GMT [17456] LOG: listening on IPv6 address "::1", port 5432
2022-09-30 12:50:05.526 GMT [7656] LOG: database system was shut down at 2022-09-30 12:49:40 GMT
2022-09-30 12:50:06.504 GMT [17456] LOG: database system is ready to accept connections
I believed that the default user name is postgres, but does seem to work.
Running some commands in another command prompt window raises the error:
psql -u postgres
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "postgres" does not exist
# trying to use my Windows username instead:
psql -u my_windows_username
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "my_windows_username" does not exist
In the Postgres connection window there are the same errors:
2022-09-30 12:50:05.195 GMT [17456] LOG: starting PostgreSQL 14.5, compiled by Visual C++ build 1914, 64-bit
2022-09-30 12:50:05.203 GMT [17456] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-09-30 12:50:05.203 GMT [17456] LOG: listening on IPv6 address "::1", port 5432
2022-09-30 12:50:05.526 GMT [7656] LOG: database system was shut down at 2022-09-30 12:49:40 GMT
2022-09-30 12:50:06.504 GMT [17456] LOG: database system is ready to accept connections
2022-09-30 12:50:31.204 GMT [10812] FATAL: role "my_windows_username" does not exist
2022-09-30 12:50:31.499 GMT [2312] FATAL: role "my_windows_username" does not exist
2022-09-30 12:51:18.550 GMT [14492] FATAL: role "postgres" does not exist
2022-09-30 12:58:58.058 GMT [18144] FATAL: role "my_windows_username" does not exist
Any thoughts about how to fix that? Thank you.
Related
I have a docker instance and I have changed the file =:
"/var/lib/postgreqsql/data/pg_hba.conf"
And it now has errors.
It appears that this is preventing me actually connecting to the docker instance.
docker logs --tail 20 postgres
2022-08-04 00:30:26.392 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-08-04 00:30:26.392 UTC [1] LOG: listening on IPv6 address "::", port 5432
2022-08-04 00:30:26.417 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-08-04 00:30:26.451 UTC [1] LOG: end-of-line before authentication method
2022-08-04 00:30:26.451 UTC [1] CONTEXT: line 87 of configuration file "/var/lib/postgreqsql/data/pg_hba.conf"
2022-08-04 00:30:26.451 UTC [1] FATAL: could not load pg_hba.conf
2022-08-04 00:30:26.453 UTC [1] LOG: database system is shut down
When I try and connect I get a consistent message as follows:
root#VM01:~/vm01-docker# docker exec -u root -it postgres bash
Error response from daemon: Container 4545dcba980215c is restarting, wait until the container is running
root#VM01:~/vm01-docker#
Stopping and starting as follows:
docker-compose stop postgres
docker-compose start postgres
Has no impact the issue remains.
What I need to do is be able to connect again to the instance and edit the file pg_hba.conf again to correct the fault but I am not sure how I can. (I am a docker newb.)
PostgreSQL init process complete; ready for start up.
2022-05-16 19:28:51.674 UTC [1] LOG: starting PostgreSQL 14.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027, 64-bit
2022-05-16 19:28:51.674 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-05-16 19:28:51.674 UTC [1] LOG: listening on IPv6 address "::", port 5432
2022-05-16 19:28:51.677 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-05-16 19:28:51.681 UTC [51] LOG: database system was shut down at 2022-05-16 19:28:51 UTC
2022-05-16 19:28:51.684 UTC [1] LOG: database system is ready to accept connections
2022-05-16 19:29:07.610 UTC [59] LOG: invalid length of startup packet
2022-05-16 19:29:07.611 UTC [58] LOG: invalid length of startup packet
2022-05-16 19:29:07.612 UTC [60] LOG: invalid length of startup packet
2022-05-16 19:29:08.647 UTC [62] LOG: invalid length of startup packet
2022-05-16 19:29:08.650 UTC [61] LOG: invalid length of startup packet
2022-05-16 19:29:08.652 UTC [63] LOG: invalid length of startup packet
Any help would be appreciated I couldn't figure out
Docker composer file
version: '3.9'
services:
postgres:
image: postgres:14-alpine
ports:
- 5432:5432
volumes:
- ~/apps/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=S3cret
- POSTGRES_USER=citizix_user
- POSTGRES_DB=citizix_db
Using ubuntu 20.4
Something, probably a monitoring system, is establishing TCP connections to the database server, then closing them without sending a correct PostgreSQL connection packet.
You can include %h in your log_line_prefix to see the client address of these connections, which may help identify the culprit.
The solution is to get the monitoring system to establish a database connection rather than only a TCP connection. Not only will that get rid of the message, but it will make the test much more useful.
I'm running wg-quick.service on system startup to establish a VPN tunnel:
root#db ~ # cat /usr/lib/systemd/system/wg-quick#.service
[Unit]
Description=WireGuard via wg-quick(8) for %I
After=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target
PartOf=wg-quick.target
Documentation=man:wg-quick(8)
Documentation=man:wg(8)
Documentation=https://www.wireguard.com/
Documentation=https://www.wireguard.com/quickstart/
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity
[Install]
WantedBy=multi-user.target
I want postgresql to listen on the wireguard address - 10.100.0.107:
root#db ~ # cat /etc/postgresql/13/main/conf.d/db1.conf | grep listen
listen_addresses = '127.0.0.1,10.100.0.107' # what IP address(es) to listen on;
After reboot I got following errors in my postgresql log:
2021-06-23 19:44:26.389 UTC [831] LOG: starting PostgreSQL 13.3 (Ubuntu 13.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-06-23 19:44:26.389 UTC [831] LOG: listening on IPv4 address "127.0.0.1", port 5432
2021-06-23 19:44:26.395 UTC [831] LOG: could not bind IPv4 address "10.100.0.107": Cannot assign requested address
2021-06-23 19:44:26.395 UTC [831] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2021-06-23 19:44:26.395 UTC [831] WARNING: could not create listen socket for "10.100.0.107"
2021-06-23 19:44:26.395 UTC [831] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-06-23 19:44:26.411 UTC [880] LOG: database system was shut down at 2021-06-23 19:43:14 UTC
2021-06-23 19:44:26.422 UTC [831] LOG: database system is ready to accept connections
Sadly, postgresql does not accept connections at 10.100.0.107.
Restart of postgresql after server reboot helps.
Also set listen_addresses='*' helps too.
But I would like to accept connections to only the specified addresses: 127.0.0.1, 10.100.0.107. How can I start a postgresql service after successfully initializing the wg-quick service?
Thanks!
I have created a PostgreSQL 13.1 cluster with 1` where I have 2 standby and 1 primary.
Here I have used scram-sha-256as authentication mode for client where my cluster is config with TLS.
When I started my PostgreSQL server, I got a continuous fatal log.
the log is:
UTC [181] FATAL: expected SASL response, got message type 88
postgresql.conf
wal_level = replica
max_wal_senders = 90
wal_keep_size = 64
wal_log_hints = on
hot_standby = on
password_encryption = scram-sha-256
recovery_target_timeline = 'latest'
primary_conninfo = 'application_name=<application_name> host=<host_name> password=<Postgres_password sslmode=verify-full sslrootcert=<path_to_ca_cert>/ca.crt'
promote_trigger_file = '/run_scripts/tmp/pg-failover-trigger'
...
<some other basic config>
...
pg_hba.conf
#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 scram-sha-256
local replication all scram-sha-256
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256
host replication postgres 0.0.0.0/0 scram-sha-256
host all all ::/0 scram-sha-256
host replication postgres ::/0 scram-sha-256
Is it possible to add scram-sha-256 for tls config cluster? If yes, then how can I do it?
Here is how I have tried to connect as a client.
$ export PGPASSWORD=<POSTGRES_PASSWORD>
$ export PGUSER=<POSTGRES_USER>
$ psql -w -h <hostname>
psql (13.1)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=#
I don't see any error from my client site but get continuous fatal log.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/pv/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
sh: locale: not found
2021-03-03 07:43:56.823 UTC [35] WARNING: no usable system locales were found
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/pv/data -l logfile start
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
waiting for server to start....2021-03-03 07:44:03.835 GMT [42] LOG: skipping missing configuration file "/etc/config/user.conf"
2021-03-03 07:44:03.836 GMT [42] LOG: skipping missing configuration file "/etc/config/user.conf"
2021-03-03 07:44:03.996 UTC [42] LOG: starting PostgreSQL 13.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
2021-03-03 07:44:03.996 UTC [42] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-03-03 07:44:03.996 UTC [42] LOG: listening on IPv6 address "::", port 5432
2021-03-03 07:44:04.073 UTC [42] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-03-03 07:44:04.187 UTC [43] LOG: database system was shut down at 2021-03-03 07:43:59 UTC
2021-03-03 07:44:04.237 UTC [44] FATAL: the database system is starting up
2021-03-03 07:44:04.281 UTC [42] LOG: database system is ready to accept connections
done
server started
ALTER ROLE
/run_scripts/role/start.sh: ignoring /var/initdb/*
waiting for server to shut down...2021-03-03 07:44:04.387 UTC [42] LOG: received fast shutdown request
.2021-03-03 07:44:04.478 UTC [42] LOG: aborting any active transactions
2021-03-03 07:44:04.480 UTC [42] LOG: background worker "logical replication launcher" (PID 51) exited with exit code 1
2021-03-03 07:44:04.482 UTC [45] LOG: shutting down
2021-03-03 07:44:05.169 UTC [56] FATAL: the database system is shutting down
.2021-03-03 07:44:05.702 UTC [57] FATAL: the database system is shutting down
2021-03-03 07:44:05.806 UTC [58] FATAL: the database system is shutting down
2021-03-03 07:44:06.217 UTC [59] FATAL: the database system is shutting down
..2021-03-03 07:44:07.648 UTC [60] FATAL: the database system is shutting down
2021-03-03 07:44:07.853 UTC [61] FATAL: the database system is shutting down
2021-03-03 07:44:08.163 UTC [42] LOG: database system is shut down
done
server stopped
2021-03-03 07:44:08.208 GMT [25] LOG: skipping missing configuration file "/etc/config/user.conf"
2021-03-03 07:44:08.208 GMT [25] LOG: skipping missing configuration file "/etc/config/user.conf"
2021-03-03 07:44:08.487 UTC [25] LOG: starting PostgreSQL 13.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
2021-03-03 07:44:08.487 UTC [25] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-03-03 07:44:08.487 UTC [25] LOG: listening on IPv6 address "::", port 5432
2021-03-03 07:44:08.688 UTC [25] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-03-03 07:44:08.895 UTC [67] LOG: database system was shut down at 2021-03-03 07:44:07 UTC
2021-03-03 07:44:08.905 UTC [68] FATAL: the database system is starting up
2021-03-03 07:44:08.945 UTC [69] FATAL: the database system is starting up
2021-03-03 07:44:08.946 UTC [70] FATAL: the database system is starting up
2021-03-03 07:44:08.991 UTC [25] LOG: database system is ready to accept connections
2021-03-03 07:44:15.990 UTC [94] FATAL: expected SASL response, got message type 88
2021-03-03 07:44:16.011 UTC [95] FATAL: expected SASL response, got message type 88
2021-03-03 07:44:30.197 UTC [108] FATAL: expected SASL response, got message type 88
2021-03-03 07:44:31.324 UTC [110] FATAL: expected SASL response, got message type 88
2021-03-03 07:44:57.571 UTC [114] FATAL: expected SASL response, got message type 88
2021-03-03 07:44:57.729 UTC [115] FATAL: expected SASL response, got message type 88
2021-03-03 07:45:07.982 UTC [127] FATAL: expected SASL response, got message type 88
2021-03-03 07:45:08.020 UTC [128] FATAL: expected SASL response, got message type 88
2021-03-03 07:45:18.135 UTC [140] FATAL: expected SASL response, got message type 88
2021-03-03 07:45:18.173 UTC [141] FATAL: expected SASL response, got message type 88
The problem was with the go-client i was trying to use to connect my server. The problem was solved when i tried https://github.com/lib/pq client instead of https://github.com/go-pg/pg.
I have personal AWS EC2 server and I'm using ssh into this server. I installed PostgreSQL on the EC2 instance, cerated a PostgreSQL RDS, and trying to connect to the RDS from EC2 CLI. I get following error:
Is the server running on host "db-xxxx.us-east-2.rds.amazonaws.com" and accepting
TCP/IP connections on port 5432?
I have:
- change RDS to publicly accessible
- added listen_addresses = '*' to postgres.conf
- added 0.0.0.0/0 md5 to pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/0 md5
ensured both EC2 and RDS have same security group
added security-group-for-inbound-nfs-xx to RDS
enabled IAM authorization on RDS
output of "service postgresql status" shows postgres is running and listening on the port 5432
Redirecting to /bin/systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-06-03 04:28:54 UTC; 20min ago
Process: 3065 ExecStartPre=/usr/libexec/postgresql-check-db-dir %N (code=exited, status=0/SUCCESS)
Main PID: 3070 (postmaster)
CGroup: /system.slice/postgresql.service
├─3070 /usr/bin/postmaster -D /var/lib/pgsql/data
├─3084 postgres: logger process
├─3089 postgres: checkpointer process
├─3090 postgres: writer process
├─3091 postgres: wal writer process
├─3092 postgres: autovacuum launcher process
├─3093 postgres: stats collector process
└─3094 postgres: bgworker: logical replication launcher
I see postgres is running and listning on the port 5432.
postmaster[3070]: 2020-06-03 04:28:54.168 UTC [3070] LOG: listening on IPv4 address "0.0.0.0", port 5432
Jun 03 04:28:54 ip-172-xx-xx-xx9.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.168 UTC [3070] LOG: listening on IPv6 address "::", port 5432
Jun 03 04:28:54 ip-172-xx-xx-xx9.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.169 UTC [3070] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Jun 03 04:28:54 ip-172-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.171 UTC [3070] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Jun 03 04:28:54 ip-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.198 UTC [3070] LOG: redirecting log output to logging collector process
Jun 03 04:28:54 ip-xx-xx-xx.us-east-2.compute.internal postmaster[3070]: 2020-06-03 04:28:54.198 UTC [3070] HINT: Future log output will appear in directory "log".
Jun 03 04:28:54 ip-172-31-36-109.us-east-2.compute.internal systemd[1]: Started PostgreSQL database server.
I have verified everything provided here:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
https://aws.amazon.com/premiumsupport/knowledge-center/rds-connectivity-instance-subnet-vpc/
What am I missing? Thanks for the help.
Well, RDS will tell you the endpoint of your PSQL, and the default port would be 5432 right. But I suggest you do the double-check if the endpoint you connected is the same with the RDS dashboard.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
I had the same issue with identical error. It was fixed when I added Private IP of my EC2 instance to security group used by the instance of my PostgreSQL database from RDS.