mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

flask-tutorial error-- Open failed: connection failed: connection refused #413

Closed lbielicki closed 9 months ago

lbielicki commented 9 months ago

Hello all,

It looks like my Dockerfile is building correctly, but I'm running into an issue with port forwarding. I've tried a couple of things but most recently:

log in with ssh Liann.Bielicki.24@lambda.compute.cmc.edu -p 5055 -L localhost:8899:localhost:5055 and run

lambda-server:~ $ docker run -d -p 8899:5055 flask-tutorial
e11462ac7d50ee1b4d9732ad865fe57020186876be51c6062828c268297a8ed7
lambda-server:~ $ channel 3: open failed: connect failed: Connection refused
channel 4: open failed: connect failed: Connection refused

which gives me the error described in the title. when I refresh in the browser (localhost:8899) the error message repeats and grows longer. has anyone else run into this? any advice on how to format the port forwarding (or point me elsewhere) is appreciated!

oliver-ricken commented 9 months ago

@lbielicki I'm also running into the same issue. In the terminal window where you initialized the Docker container with docker run, what does the following line return for you?

docker logs 'CONTAINER ID'

This is the output on my end when I run that line:

* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 125-442-018

I'm thinking that the issue might be related to the Running on http://0.0.0.0:5000/ line. From what I understand, this means that the Flask application inside the container is running on port 5000. However, in my docker run command, I think that I specified a different mapping for the container port when I specified:

docker run -d -p host_port:container_port flask-tutorial

Essentially, I think the issue is that the container_port in the docker run command that I specify does not align with the container that the Flask app is running on, indicated by the output of the docker logs command.

Any input would be appreciated!

lbielicki commented 9 months ago

@oliver-ricken I was able to resolve this error, but not sure what directly caused it/why the error was coming up, so I'll summarize what I did: I used python3 app.py to test my file, and figured out I still needed to fix some small errors such as changing the F in From to lowercase I had to run pip install flask in the terminal I logged in using -L localhost:8899:localhost:8899 at the end of my usual login, and similarly only used docker run -d -p 8899:8899 flask-tutorial when it came time to connect

edit: btw I did not get the same message when I ran docker logs 'CONTAINER ID', I think I had a separate problem with the container