question

RahulModpur-6712 avatar image
0 Votes"
RahulModpur-6712 asked OuryBa-MSFT commented

Getting TCP reset for some existing azure postgres connections

I'm using a private endpoint to connect to an azure postgres instance but i'm getting TCP reset (write tcp <client-ip>:<client-port>-><private endpoint ip>:5432: write: connection reset by peer) for some of the existing connections. We never close our idle connections, timeout doesn't seem to be an issue because i found some 2 days old connection in pg_stat_activity. What could be potential reasons for it ?

Thanks

azure-database-postgresql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

OuryBa-MSFT avatar image
0 Votes"
OuryBa-MSFT answered OuryBa-MSFT commented

@RahulModpur-6712 Thank you for posting your question on Microsoft Q&A and sorry for the delay response.



When the application attempts to use the connection object, the connection has gone “stale” and the client application throws an exception from attempting to send query data over the “open” connection. The client-side logic catches the exception and the TCP connection is closed. The PostgreSQL backend detects that the client-side connection was closed and reports the dropped connection as Windows error WSAECONNRESET (10054) Connection reset by peer: An existing connection was forcibly closed by the remote host. The ‘remote host’ here is the client, which is separate from the Postgres server.


The only way to understand exactly what is causing the issue is to capture network trace at the client-side at the time when the issue occurrs. Network Traces can be captured by different applications such as NetMon, WireShark, Fiddler, etc.


If you are using a Linux client and the tools mentioned above don't work, you can manually generate network dump as in the following command:


tshark -i any -n -b filesize:204800 -w date +%y%m%d-%H:%M:%S.pcap -b files:1000

or

tcpdump -i any -w date +%y%m%d-%H:%M:%S.pcap -G 300 -W 1000


Note: If you enable network capture, monitor your disk space and purge as needed to ensure you don’t run out of space.

https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/troubleshoot-postgresql-an-existing-connection-was-forcibly/ba-p/925164

Regards,
Oury

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RahulModpur-6712 Please do not forget to mark as accepted answer if the above reply was helpful. Feel free to reach out if you need further assistance.

Regards,
Oury

0 Votes 0 ·

Hi @RahulModpur-6712 Please do not forget to mark as accepted answer if the above reply was helpful. Feel free to reach out if you need further assistance.

Regards,
Oury

0 Votes 0 ·