RabbitMq Container connection

108 views
Skip to first unread message

Alex Kiprono

unread,
Mar 26, 2024, 1:55:45 AM3/26/24
to golang-nuts
am having this error despite setting up environments on yml file and even testing by login into the rabbitMq localhost of the rabbitmq container.


any assistance will be highly appreciated

yml compose file
version: "3"

services:

# Create service with RabbitMQ.
message-broker:
image: rabbitmq:3-management-alpine
ports:
- "5673:5672" # Corrected port mapping for AMQP connections
- "15673:15672" # for serving RabbitMQ GUI
volumes:
- ${HOME}/rabbitmq2/data/:/var/lib/rabbitmq
- ${HOME}/rabbitmq2/log/:/var/log/rabbitmq
restart: always
networks:
- dev1-network

# Create service with sender.
sender:
build:
context: .
dockerfile: Dockerfile-sender
ports:
- "3000:3000"
environment:
AMQP_SERVER_URL: amqp://guest:guest@localhost:5672/ # Use localhost for connection
restart: always
networks:
- dev1-network
depends_on:
- message-broker

# Create service with message consumer.
consumer:
build:
context: .
dockerfile: Dockerfile-consumer
environment:
AMQP_SERVER_URL: amqp://guest:guest@localhost:5672/ # Use localhost for connection
restart: always
networks:
- dev1-network
depends_on:
- sender
- message-broker

networks:
# Create a new Docker network.
dev1-network:
driver: bridge





Screenshot from 2024-03-26 08-50-52.png

Kurtis Rader

unread,
Mar 26, 2024, 2:17:08 AM3/26/24
to Alex Kiprono, golang-nuts
Please don't use screenshots for plain text. Screenshots are hard to read and we can't copy/paste the text in the image.

The error says it can't connect to 172.21.0.1 port 5672. Do you perhaps have the port numbers reversed in your "yml compose file"? Is the IP address correct?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0d8bf2eb-6600-4f0b-bf07-06fef5a185c1n%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Cleberson Pedreira Pauluci

unread,
Mar 26, 2024, 11:03:30 PM3/26/24
to golang-nuts
I think @Kurtis Rader is right.

@Alex Kiprono, the sender and consumer services are connecting to localhost:5672, but the message-broker service has exposed its port as 5673:5672.
Try using localhost:5673 in your AMQP_SERVER_URL environment variables or change the message-broker service container and host port to 5672:5672.

Cleberson Pauluci.
Reply all
Reply to author
Forward
0 new messages