Blok net for an specific app, except on local connection (127) and some port

Title explain for itself:
Block all incoming and outgoing connections to a application, but allow for IP 127.0.0.1 and also an specific port number.

Please, help me.

Create two network zones

local_0 = 0.0.0.0
local_127 = 127.0.0.1

Create the below rules for the application:

allow TCP out from in [local_0] to in [local_127] source port any destination port any
block IP in/out from MAC Any to MAC Any IP protocol any

you can tick the box to log if the rule fires.

You may need to create rules to allow TCP out from in [local_127] to in [local_0], and in [local_127] to in [local_127] and in [local_0] to in [local_0], too. Your logs will tell you if that’s being blocked. If no blocks to those zones happen, you won’t need those rules. But the first two rules should be all you need.

127.0.0.1 already exists its called Loopback zone, under network zones.