Search code examples
pythondockerubuntugetpostman

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

Solution

  • Try localhost:6001 not internet address

    You can also try any of your system local ipaddress , you find ipaddress by typing ifconfig or ipconfig if you are in linux or windows respectively