(Odoo) Why can't i connect to the server when using pganonymizer? - subprocess

I am trying to anonymize some data in my database but I am getting the following Error.
Postgres is running on port 5432 in the container and I am exposing it on the host on port 5433.
ports:
- "5433:5432"
Am I supposed to add something in my odoo.conf file?
Thanks

The newest version of pganonymizer needs you to specify the postgres hostname and port in the subprocess command.
if env.get('PGHOST'):
cmd.extend(['--host', env['PGHOST']])
if env.get('PGPORT'):
cmd.extend(['--port', env['PGPORT']])

Related

Error: P1001: Can't reach database server at `localhost`:`5432`

I'm having a problem when running the npx prisma migrate dev command. Docker desktop tells me that the database is running correctly on port 5432 but I still can't see the problem.
I tried to put connect_timeout=300 to the connection string, tried many versions of postgres and docker, but I can't get it to work.
I leave you the link of the repo and photos so you can see the detail of the code.
I would greatly appreciate your help, since I have been lost for a long time with this.
Repo: https://github.com/gabrielmcreynolds/prisma-vs-typeorm/tree/master/prisma-project
Docker-compose.yml
version: "3.1"
services:
postgres:
image: postgres
container_name: postgresprisma
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=santino2002
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
Error:
Error: P1001: Can't reach database server at localhost:5432
Please make sure your database server is running at localhost:5432.
Docker ps show this:
Looks like the application and the database are running on two separate containers. So, in this case, connecting to localhost:5432 from the application container will try to connect to 5432 port within that container and not in the docker host's localhost.
To connect to database from the application container, use postgres:5432 (If they are on the same network) or <dockerhost>:5432.
Your docker ps output is showing that your postgres container has no ports connected to your local network.
It should look something similiar to this on ports column.
0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
But yours is just 5432/tcp
You need to open ports for your postgres container.
Your docker-compose.yml file you posted in the question is correct. Probably you started postgres container with no ports first, then changed your docker-compose.yml file to have ports. So you just need to restart it now.
Use docker compose down && docker compose up --build -d to do that.

Postgres/Docker : Can't connect to localhost:5432

I am running a postgres image using a docker-compose.yml file (not in detached mode). I have created two users and two databases there. In my bash terminal I logged into both users and when I typed \conninfo it said that
You are connected to database "db1" as user "user1" on host "localhost" (address "127.0.0.1") at port "5432".
and "db2" and "user2" for the other one.
When I typed the command "sudo netstat -plunt | grep postgres" it returned the following
tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN 953/postgres
I have a few questions.
1\ Why does it say port 5432 in the first one and 5433 in the second??
2\ When I type localhost:5432 in the url I don't see any page. It says
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
Why can't I see anything in the web page at the above address??
3\ In my vscode terminal I am also getting these two error messages
2021-12-25 22:03:51.887 UTC [45] LOG: invalid length of startup packet
ERROR: relation public.databasechangeloglock does not exist at character 22
Do you know why I am getting these errors?
My docker-compose.yml file is as follows (shown only partly).
version: "3.4"
services:
sumo-db:
image: postgres-sumo:1.4.0
environment:
- POSTGRES_PASSWORD=password
- DB_NAME_1=db1
- DB_USER_1=user1
- DB_PASS_1=pass1
- DB_NAME_2=db2
- DB_USER_2=user2
- DB_PASS_2=pass2
volumes:
- sumo-db-data:/var/lib/postgresql/data
restart: on-failure
ports:
- 5432:5432
networks:
- sumo
If you need further information feel free to ask me. As always thank you.
Inshaf
If the docker hypervisor is capturing connections to 5432 on the host and tunneling them into the container, netstat will attribute this to the hypervisor process, not to a PostgreSQL process. netstat doesn't know who is on the other end of the tunnel, only its own end. Now it could recognize 5432 as being a traditional PostgreSQL port and label it that way, but -n tells it not to. Apparently you also have a 2nd instance of PostgreSQL, this one running directly on the host and on port 5433.
When I type localhost:5432 in the url I don't see any page.
A URL is something you can type, not something you type other things into. If you are putting that into the address bar of a web browser, that is not how you connect (successfully) to databases.
What is a vscode terminal? Does it have anything to do with either PostgreSQL or docker? Does the message mean that this terminal committed those errors, or someone else committed those errors against it?

Error creating postgres container with Docker

I'm initializing my studies with docker. When I creating the postgreSQL container with Docker, appear this error:
I've already reinstall docker and tried change the database port, but must be don't have success
The error indicates that the 5432 port is already in use, in the HOST. This means that this port is occupied by another application. This could be for example a Postgres instance that you have on your machine or maybe another container using up this port.
The port option is -p hostPort:ContainerPort, so to have access to the Postgres port of the container which is 5432 in the host at port 5000 try:
-p 5000:5432

Docker Compose Postgres always ended by timeout or connection refused

Got a small question here. I suppose I've done something wrong at a moment but i can't find where and it's been +2 hours I'm turning around.
So Basically, I've created a docker-compose with Postgis (Postgres). I wanted to connect on it through Tableplus.
However, I can't ...
2 kind of error keep appearing :
When I try to connect basically on 127.0.0.1, it's keep telling me connection refused
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
When I try to use the docker IPAddress - 172.23.0.2 (docker inspect the image's ID to get the IP address of the image)
could not connect to server: Operation timed out
Is the server running on host "172.23.0.2" and accepting
TCP/IP connections on port 5432?
Here is my docker-compose.yml
version: '3.5'
services:
db:
image: kartoza/postgis:12.1
environment:
- POSTGRES_USER=user1
- POSTGRES_PASSWORD=password1
- POSTGRES_DB=database_db
volumes:
- data_db_volume:/var/lib/postgresql/12
ports:
- "5432:5432"
volumes:
data_db_volume:
At first, when I tried to connect, it was telling me: role user1 doesn't exist.
So to stop this I ran: brew services stop postgresql on my machine
I think a psql was running locally on the same port because with lsof -n -i:5432 | grep LISTEN i keep having information (it stop since I ran stop Postgresql)
Alright so after few days of research and trying on another computer, it seems it was coming from 2 points: the new docker software with a graphic interface that I didn't use before, once this running correctly and a prune done from this place everything started to work fine so I think something was causing error due to an outdated piece of software.
Thank's everyone

How to connect to postgresql instance in with Docker Toolbox with pgadmin4 client

i'm new to Docker, and i'm running it with Docker Toolbox cause i have win 10 family.
I have a training project where there is a database to put up with docker-compose.
Here is the docker-compose.yml (it's given to me, but i can modify it).
version: '2'
services:
myerp.db:
image: postgres:9.4
ports:
- "127.0.0.1:9032:5432"
volumes:
# - "./data/db:/var/lib/postgresql/data"
- "./init/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
environment:
- POSTGRES_DB=db_myerp
- POSTGRES_USER=usr_myerp
- POSTGRES_PASSWORD=myerp
When i run that through Docker with docker-compose up it seems ok,
but i'm unable to connect to it through a server in pgadmin4
I'm not sure of the connexion setup i'm suppose to put because of Docker ToolBox, where in general to access the running instance you don't use 127.0.0.1 but 192.168.99.100 by defaut.
Anyway, if i configure a postgresql server with
Hostname: 127.0.0.1
Port: 9032
Username and password as written up, i have
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 9032?
If i change the IP in docker-compose for 192.168.99.100, i manage to connect,
but the database is not initialized although there are sql files in the folder
\init\db\docker-entrypoint-initdb.d :
01_create_schema.sql
02_create_tables.sql
21_insert__data_demo.sql
So is it my connexion that is wrongly setup ?
Or should i do it with 192.168.99.100, and it's the initialisation setup that is wrong in the docker-compose ?
Thanks for help !
Ok so i solve the problem, but unfortunately without Docker Toolbox.
I bought a key for windows 10 pro (6€), upgraded the system really fast, and installed Docker Desktop.
Everything worked instantly.
Before the connexion ip was indeed 192.168.99.100, but i don't know why the sql scripts where not copied in the virtual environment, and the folder
/docker-entrypoint-initdb.d
remained empty.
So my solution was to upgrade the system, and everything is fine !