Docker Community Forums

Share and learn in the Docker community.

Docker curl: (56) Recv failure


(Creaprog) #1

Hello guys,

I am novice with Docker :frowning:
I have this error :
curl -v localhost:8080
curl: (56) Recv failure

My Dockerfile :

FROM python:latest
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
VOLUME /usr/src/app
EXPOSE 8080
CMD [ “python”, “./server.py” ]

docker build -t api .
With my latop 0 problem, with docker curl: (56) Recv failure

Logs my service web Python :
docker run --name api -p 8080:8080 api

  • Serving Flask app “server” (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: off
    /usr/local/lib/python3.7/site-packages/flask_sqlalchemy/init.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
    'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and ’
  • Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

After 1 curl, 0 signal :frowning:

Do you have idea ?

THX


(Faical Yannick Palingwende Congo) #2

Hi creaprog,
I have a very trivial question.
Are you overwriting the default flask port (5000) within server.py somehow?
If not, I think your issue might be related to the fact that you are mapping the wrong port number.
You should instead try -p 8080:5000
I hope it helps.


(Creaprog) #3

Yes.

thx but, same problem :frowning:


(Faical Yannick Palingwende Congo) #4

What happens when you try curling from within the container 5000?
If that works. My next worry would be to look for your machine firewall specs.
56 from curl means the connection was reset.
Do you have a running firewall? You might have to allow 8080.


(Creaprog) #5

In my container : curl: (7) Failed to connect to 127.0.0.1 port 5000: Connection refused

I don’t have firewall, same error with my Mac. I have try with ubuntu and Mac.


(Faical Yannick Palingwende Congo) #6

Oh! Within the container? Interesting! This means that your flask server is not running (crashed) or that you are using a flask config that has overwritten the default port 5000 (may be 8080?). In case of a crash, may be try to attach to the running container and investigate that. Then try running the flask server yourself to see the reason of the crash. Otherwise investigate the appropriate internal port your server is running off and that may work for the mapping.


(Creaprog) #7

I have the same problem he does : https://github.com/moby/moby/issues/21650

My serer flask don’t crash because i see the log.

With container off :
curl: (7) Failed to connect to 127.0.0.1 port 8080

With container on :
curl: (56) Recv failure

YEAH !!! SOLVED

Before :
if name == “main”:
app.run(debug=True, port=8080)

After :
if name == “main”:
app.run(debug=True, port=8080, host=‘0.0.0.0’)

THX :slight_smile: