Do I need to open a port on the container?

I am building a Flask app in Python3 and when I start the app it states go to
When I try to reach the server via it’s IP:5000 I can’t.

Do I need to open that port somehow on the container?

You can set up the app to listen to all interfaces, therefore it will work without forwarding. It is a common issue when an app listens by default to loopback.

If you do not wish to make the app to listen to all interfaces, then if you have LXD 3.3 or newer, you can set up a proxy device to redirect that container port to a port on the loopback interface of the host.

What I want to do is that I control what ports it listens to? That is noraml ip-tabels?
And how do I open for all ports?

See the Flask documentation at
Specifically, see the option --host=, which makes your Flask app to be readily accessible by the host, using the IP address of the container.

That means that you do not need to use iptables. Using them would be overkill for your case.

1 Like

Sorry for not being here for such a long time, but the host part was the thing I was looking for, now the API is reacable for inside the network. Just as I want it to be.