English 中文(简体)
无法连接到服务器数据库系统的启动包的无效长度已被关闭, 收到快速关闭请求( pgadmin postgres docker)
原标题:invalid length of startup packet-unable to connect to server-database system was shut down-received fast shutdown request (pgadmin postgres docker)
I want to connect to the postgres database in my current image with pgadmin located on my local machine. Using a host Macbook air M1 docker desktop app, while trying to start a postgres docker container with the latest image using the command: docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=password -d postgres I cannot connect to the pgadmin using localhost:5432 and received the following shutdown error 2024-08-12 09:20:51 This user must also own the server process. 2024-08-12 09:20:51 2024-08-12 09:20:51 The database cluster will be initialized with locale "en_US.utf8". 2024-08-12 09:20:51 The default database encoding has accordingly been set to "UTF8". 2024-08-12 09:20:51 The default text search configuration will be set to "english". 2024-08-12 09:20:51 2024-08-12 09:20:51 Data page checksums are disabled. 2024-08-12 09:20:51 2024-08-12 09:20:51 fixing permissions on existing directory /var/lib/postgresql/data ... ok 2024-08-12 09:20:51 creating subdirectories ... ok 2024-08-12 09:20:51 selecting dynamic shared memory implementation ... posix 2024-08-12 09:20:51 selecting default max_connections ... 100 2024-08-12 09:20:51 selecting default shared_buffers ... 128MB 2024-08-12 09:20:51 selecting default time zone ... Etc/UTC 2024-08-12 09:20:51 creating configuration files ... ok 2024-08-12 09:20:51 running bootstrap script ... ok 2024-08-12 09:20:51 performing post-bootstrap initialization ... ok 2024-08-12 09:20:51 syncing data to disk ... ok 2024-08-12 09:20:51 2024-08-12 09:20:51 2024-08-12 09:20:51 Success. You can now start the database server using: 2024-08-12 09:20:51 2024-08-12 09:20:51 pg_ctl -D /var/lib/postgresql/data -l logfile start 2024-08-12 09:20:51 2024-08-12 09:20:51 waiting for server to start....2024-08-12 06:20:51.724 UTC [48] LOG: starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-08-12 09:20:51 2024-08-12 06:20:51.725 UTC [48] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-08-12 09:20:51 2024-08-12 06:20:51.726 UTC [51] LOG: database system was shut down at 2024-08-12 06:20:51 UTC 2024-08-12 09:20:51 2024-08-12 06:20:51.728 UTC [48] LOG: database system is ready to accept connections 2024-08-12 09:20:51 done 2024-08-12 09:20:51 server started 2024-08-12 09:20:51 2024-08-12 09:20:51 /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* 2024-08-12 09:20:51 2024-08-12 09:20:51 2024-08-12 06:20:51.857 UTC [48] LOG: received fast shutdown request 2024-08-12 09:20:51 waiting for server to shut down....2024-08-12 06:20:51.857 UTC [48] LOG: aborting any active transactions 2024-08-12 09:20:51 2024-08-12 06:20:51.858 UTC [48] LOG: background worker "logical replication launcher" (PID 54) exited with exit code 1 2024-08-12 09:20:51 2024-08-12 06:20:51.858 UTC [49] LOG: shutting down 2024-08-12 09:20:51 2024-08-12 06:20:51.859 UTC [49] LOG: checkpoint starting: shutdown immediate 2024-08-12 09:20:51 2024-08-12 06:20:51.863 UTC [49] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.004 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/14EA290, redo lsn=0/14EA290 2024-08-12 09:20:51 2024-08-12 06:20:51.864 UTC [48] LOG: database system is shut down 2024-08-12 09:20:51 done 2024-08-12 09:20:51 server stopped 2024-08-12 09:20:51 2024-08-12 09:20:51 PostgreSQL init process complete; ready for start up. 2024-08-12 09:20:51 2024-08-12 09:20:51 initdb: warning: enabling "trust" authentication for local connections 2024-08-12 09:20:51 initdb: hint: 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. 2024-08-12 09:20:51 2024-08-12 06:20:51.979 UTC [1] LOG: starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-08-12 09:20:51 2024-08-12 06:20:51.981 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-08-12 09:20:51 2024-08-12 06:20:51.981 UTC [1] LOG: listening on IPv6 address "::", port 5432 2024-08-12 09:20:51 2024-08-12 06:20:51.983 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-08-12 09:20:51 2024-08-12 06:20:51.985 UTC [62] LOG: database system was shut down at 2024-08-12 06:20:51 UTC 2024-08-12 09:20:51 2024-08-12 06:20:51.989 UTC [1] LOG: database system is ready to accept connections```
问题回答
The solution lies in inspecting the container IPAddress using the command: docker inspect postgres -f "{{json .NetworkSettings.Networks }}" The result should be something like this: {"postgres-network":{"IPAMConfig":null,"Links":null,"Aliases":null,"MacAddress":"02:42:ac:14:00:02","DriverOpts":null,"NetworkID":"f5e259aecad873cb127fe0bb7af1ed5c447d3f2ec8c4a35563ac59dd143fab40","EndpointID":"25ee418515a97ca6abc991f53d99057425655bc07269155c2cacf56ab830ad7c","Gateway":"172.20.0.1","IPAddress":"172.20.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":["postgres","c428e92f9043"]}} I used the value of the IPAddress which is 172.20.0.2 to connect to pgadmin and it worked. I also used host.docker.internal and it worked.




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签