cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Docker can't connect to PostgreSQL

AF_10328563
10-Marble

Docker can't connect to PostgreSQL

Hello,
I have built the different doocker image.
When i try to run my docker-compose-postgresql.yml

I have an issue stating:

 

 

postgresql-init_1 | psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
postgresql-init_1 | Is the server running on that host and accepting TCP/IP connections?
postgresql-init_1 | connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
postgresql-init_1 | Is the server running on that host and accepting TCP/IP connections?
postgresql-init_1 | [06-09-22 13:03:33] [INFO] Postgres is unavailable - Waiting...

 

 

My PostgreSQL server is running and i can even connec to It using pgAdmin4 on those port.
Does anyone have a clue?

ACCEPTED SOLUTION

Accepted Solutions

I had the same user for the variable 

DATABASE_ADMIN_USERNAME
TWX_DATABASE_USERNAME
 
Changing to two different username did the job

View solution in original post

4 REPLIES 4

Article - "ThingWorx: Setting up a PostgreSQL database for external connections": https://www.ptc.com/en/support/article/CS238699

This does not work for me.
I tested every solution, even the `host    all    all    all    md5'

I think there could be a problem in my docker-compose-postgresql.yml

Here is my pgadmin4 page and the docker-compose file (I've erased the password for this picture but they were written)

AF_10328563_0-1654846276672.png

 

Do you have any idea?

I managed to fix the issue by starting my postgresql image inside the docker-compose

pg_container:
    image: postgres:13.0
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    ports:
      - "5432:5432"

However, now that I can connect, I get this issue:

AF_10328563_0-1654867332075.png

postgresql-init_1  | [06-10-22 13:18:08] [INFO] Postgres is ready
postgresql-init_1  | + /usr/local/bin/db-setup.sh
postgresql-init_1  | [06-10-22 13:18:08][INFO] Working directory: /
postgresql-init_1  | [06-10-22 13:18:08][WARN] No admin dbname specified setting to schema postgres
postgresql-init_1  | [06-10-22 13:18:08][WARN] No dbname specified setting to schema postgres
postgresql-init_1  | [06-10-22 13:18:08][INFO] DatabaseLogin: postgres
postgresql-init_1  | [06-10-22 13:18:08][INFO] ThingworxLogin: postgres
postgresql-init_1  | [06-10-22 13:18:08][INFO] Checking for database user postgres...
postgresql-init_1  | [06-10-22 13:18:08][INFO] User postgres already exists.
postgresql-init_1  | [06-10-22 13:18:08][INFO] Checking for database postgres...
pg_container_1     | 2022-06-10 13:18:08.895 UTC [65] ERROR:  relation "system_version" does not exist at character 27
pg_container_1     | 2022-06-10 13:18:08.895 UTC [65] STATEMENT:  SELECT major_version FROM system_version order by pid desc limit 1
postgresql-init_1  | ERROR:  relation "system_version" does not exist
postgresql-init_1  | LINE 1: SELECT major_version FROM system_version order by pid desc l...
postgresql-init_1  |                                   ^
pg_container_1     | 2022-06-10 13:18:08.940 UTC [66] ERROR:  relation "system_version" does not exist at character 27
pg_container_1     | 2022-06-10 13:18:08.940 UTC [66] STATEMENT:  SELECT minor_version FROM system_version order by pid desc limit 1
postgresql-init_1  | ERROR:  relation "system_version" does not exist
postgresql-init_1  | LINE 1: SELECT minor_version FROM system_version order by pid desc l...
postgresql-init_1  |                                   ^
postgresql-init_1  | [06-10-22 13:18:08][INFO] Database schema detected, current schema version is .
postgresql-init_1  | [06-10-22 13:18:08][ERROR] Unable to determine the system version

Does anyone have an idea on how to solve it?

I had the same user for the variable 

DATABASE_ADMIN_USERNAME
TWX_DATABASE_USERNAME
 
Changing to two different username did the job
Announcements


Top Tags