Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Socket Hang Up with Postman API testing

We have deployed some APIs (few developed using Node.js/Express.js and others using Python Quart). All out our APIs are deployed using the Azure containerized instance. We have set-up periodic API monitoring through Postman. The APIs fail about 20% of the time with Error: Socket Hang Up. We never encountered this issue in development region or when accessing the APIs via browsers. What could cause this Socket Hang Up issue and how do we overcome it?

Our Node.js APIs Dockerfiles are set-up as below:

FROM node:16

WORKDIR /app

COPY package*.json ./
RUN npm install
COPY . .
RUN rm -rf .env
RUN mv production.env .env

#ENV PORT=5000
EXPOSE 5000

CMD ["npm", "run", "prod"]

The Python Quart APIs Dockerfiles are set-up as below:

FROM continuumio/miniconda3

COPY . /api/

WORKDIR /api/src

RUN conda env create -f /api/environment.yml
COPY entrypoint.sh ./
RUN chmod +x ./entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]

EXPOSE 5000

entrypoint.sh

#!/bin/bash --login
set +euo pipefail
conda activate python_env_name
set -euo pipefail

exec hypercorn --bind 0.0.0.0:5000 QuartAPI:app
like image 615
Navaneeth Avatar asked Dec 07 '25 19:12

Navaneeth


1 Answers

Seems like more of an issue in Postman than within your API. Assuming the server is not throwing/logging any errors, it's likely the response is not being handled by Postman correctly. Here are some things in Postman that may be causing this issue:

  1. In the request: Add the header the "Content-length". It should automatically calculate the value (but you can try specifying it). If you have a value specified, ensure it's correct.
  2. In Postman -> Settings -> General, ensure the "Timeout" value is high enough or "0" for forever.
  3. Postman does not like VPN's in my experience. If you are connected to a VPN when the issue is happening, please disconnect it and try it again. If this fixes it, you'll need to create a special route out around your VPN.
  4. Postman -> Settings -> General, try to disable "Send Postman Token"
  5. Last thing to try: Postman many not be handling TLS renegotiations initiated by the server, which in multiple versions of Postman lead to connection/socket error. The issue seemed to affect Postman versions around 7.1 - 7.5. You could try updating Postman to the latest version which may be the fix.
like image 181
factorypolaris Avatar answered Dec 10 '25 09:12

factorypolaris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!