[SOLVED] Can't get rid of "No route to host" error in celery


I’m stuck with an error trying to set up celery instance with rabbitmq using docker-compose.

My compose file:

version: '3.7'
    hostname: rabbit
    image: rabbitmq:3.8
      - 5672
    image: celery
      - ./:/code
      - PYTHONPATH=/code
    command: celery -A task worker
      - rabbit
      - "rabbit:rabbit"

My celery code:

from celery import Celery

app = Celery('tasks', broker='amqp://rabbit:5672/')

def add(x, y):
    return x + y

The sad outcome:

celery_1  | [2020-03-24 15:29:58,318: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@rabbit:5672//: [Errno 113] No route to host.

Do you guys have any idea what might be the issue?
I’ve tried creating a custom user, but it didn’t work (also, looks like problem is with domain resolution, not authentication)
When I docker exec to celery container I can totally ping rabbit container:

$ docker exec -ti celery-check_celery_1 ping rabbit
PING rabbit ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.077 ms
64 bytes from icmp_seq=1 ttl=64 time=0.066 ms
64 bytes from icmp_seq=2 ttl=64 time=0.069 ms

I’ve tried the same with redis and also got “no route to host”, to it must be a network configuration issue.

Problem solved.
Firewall from root OS was blocking docker ports.