This happens when UA sends `REGISTER` from a port that doesn't match the one advertised in a `CONTACT` header (for example there is a port translation (like PAT) on your firewall, or maybe a bug in UA 🤷)
Kamailio will store `AoR` with a port from `CONTACT`, and this may be not reachable. As an example see attached pictures with Zoiper and TCP: `REGISTER` packet received from port **50376** but AoR stored with port **60320**. Trying to connect to that port failed and thus error message from `tcp_do_connect()`
<img width="1024" alt="kamailio_nat_issue_1" src="https://github.com/user-attachments/assets/50e543ac-8d8f-4725-8e68-fc1f55fbb57a"> <img width="705" alt="kamailio_nat_issue_2" src="https://github.com/user-attachments/assets/ce3e05bc-01de-4e3b-bec6-3cd02694eecd"> <img width="1275" alt="kamailio_nat_issue_3" src="https://github.com/user-attachments/assets/92fb56b3-2822-4d8e-b31a-dd83d6a3e838">
👉 To fix that define `WITH_NAT`, use `received_avp` parameter of the `nathelper` module and the `registrar` module, and use `fix_nated_register()` for the `registrar` to store it in the received column in the location table
<img width="1044" alt="kamailio_nat_issue_5_fix" src="https://github.com/user-attachments/assets/764578cc-359a-440f-afa9-c329abe95c56">
<img width="684" alt="kamailio_nat_issue_4_fix" src="https://github.com/user-attachments/assets/23934bd4-f2b5-4e2e-91b4-682f47fa154c">