As per my understanding when we execute a command or query, the Postgres client sends a frontend message, and in return gets the response in the backend message format.

How do I capture and check these messages on a Linux box?

For e.g. let's say I am executing the below command via psql client

 psql --username=foo --dbname=mydb --password=foobar

I believe the client creates StartupMessage.

Is there a way to trace down this interaction? Considering server and client are running on the same machine.


I just strace -s4096 the psql program (because that is easier to do than stracing the backend) and pull the messages out of the strace output. The relevant filehandle to look for is usually 3, but I suppose that will not always be the case.


I tend to use Wireshark, it understands and interprets the PostgreSQL protocol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.