I'm in a somewhat weird situation that I don't understand:

  • I use ufw as a firewall. It's setup to drop any input connections apart from ssh
  • I have a service running locally (managed through systemd) that accepts connections on port 9500
  • I have another service managed with docker-compose. It needs to talk to the service on my host at port 9500 + a Redis container
  • Nothing needs to come in from the outside, it's all happening on my machine

UFW config:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         LIMIT IN            

Docker config:

    ...some stuf...
      - redis
      - "host.docker.internal:host-gateway"

    container_name: redis
    restart: unless-stopped
    image: redislabs/rejson:2.0.8
      - 6379:6379
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]

When I run this setup with ufw DISABLED, everything works. my_service running in Docker can talk to the service managed by systemd on port 9500 by contacting host.docker.internal:9500, and it can also talk to Redis, which is on Docker's network.

However if I ENABLE ufw, my_service can't talk to the systemd service. I don't understand why this happening. I thought this was because I didn't allow traffic coming from localhost, so I tried that:

# ufw allow from

But it didn't help, the traffic isn't coming through. Could you help me understand what is happening please?

1 Answer 1


Your docker container doesn't come from IP or from Probably it will have an IP like Use docker inspect <your container> to look up its IP address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .