Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access docker container Socket hang up error

I have successfully built and started the docker container, it is running perfectly, but when I try to access it [End point url 0.0.0.0:6001] I am getting a "socket hang up" error

GET http://0.0.0.0:6001/
Error: socket hang up

Request Headers
  User-Agent: PostmanRuntime/7.26.8
  Accept: */*
  Postman-Token: <token>
  Host: 0.0.0.0:6001
  Accept-Encoding: gzip, deflate, br
  Connection: keep-alive

Earlier it was working fine but when I removed the containers and images and rebuild it then I started getting this error

I am using Postman to make GET request and I also tried Web browser

Can anyone tell me whats the problem

--Update--

Docker File

Creating containers

# Create Virtual Network
$ sudo docker network create network1 
# Using custom network as there are multiple containers 
# which communicate with each other

# Create Containers
$ sudo docker build -t form_ocr:latest .
$ sudo docker run -d -p 6001:5000 --net network1 --name form_ocr form_ocr

netstat command output

$ netstat -nltp 
...
tcp6       0      0 :::6001                 :::*                    LISTEN      -  

docker container inspect output

$ sudo docker container inspect <container-id>

output

docker ps output

$ sudo docker ps
CONTAINER ID        IMAGE        COMMAND             CREATED        STATUS           PORTS                    NAMES
835e8cb11eee        form_ocr     "python3 app.py"    16 hours ago   Up 40 seconds    0.0.0.0:6001->5000/tcp   form_ocr
like image 236
arush1836 Avatar asked Feb 03 '26 20:02

arush1836


1 Answers

I had the same problem with fastapi container

Make sure your app is listening on 0.0.0.0 within the container

like image 75
Dhouibi iheb Avatar answered Feb 06 '26 08:02

Dhouibi iheb



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!