#Medusa not listening on 0.0.0.0 even when specified from command flag

30 messages · Page 1 of 1 (latest)

finite parcel
#

Hi!

I've dockerized my Medusa backend, nothing really complicated, just a network between the storefront and the backend, and ports exposure. I've set the entrypoint of the backend container to be medusa develop -H 0.0.0.0, so that it could be reached from the network but also from the host.

In fact, when i curl the container from the network it works just fine, but when i do it from the outside (like the terminal of my computer) it says "Recv failure: Connection reset by peer".

By googling, i noticed that this error is related to Medusa listening only to the localhost host, and so i think that the flag -H is not properly working (at least in my case).

Do someone know something more than I do? It would be really helpful. Thanks!

grave flame
#

Hello~~~

turbid raven
#

have you forwarded the port maybe?

finite parcel
#

What do you mean?

turbid raven
#

By default the server listen ok the port 9000

finite parcel
#

My medusa is listening on 9000 and docker is configured to expose 9000:9000, so i don't think i did port forwarding

turbid raven
#

in that case you are forwarding the port 9000 of your container to 9000 on your network, am i right?

finite parcel
#

I will describe you my setup

#

I have a compose file that puts up 5 containers:

  • Medusa backend (-p 9000:9000)
  • NextJS frontend (-p 10000:10000)
  • Redis (not exposed)
  • Postgres (-p 9500:5342)
  • Medusa Admin (-p 8000:8000)

All of those containers are linked together by a bridge network called store-bridge

#

The calls to localhost:9000 are working fine from the storefront, but when i run curl localhost:9000/store/products from my computer terminal it says "connection reset by peer"

turbid raven
#

shouyldn't you use the host network to be able to access it? otherwise the bridge is not link to your localhost right?

finite parcel
#

I could use the host network but it would try to avoid it if possible

#

The strange this is if, for example, i run a laravel sail container (which is basically the same setup), if i curl the Laravel container IP it works fine, and it uses a network like mine

turbid raven
#

and what if you curl your medusa container ip?

finite parcel
#

First one is Medusa, second one is Laravel

#

I do think that Medusa is listening only on calls from localhost

void badger
#

localhost?

finite parcel
#

"localhost" is a Laravel project i started just for testing and it is configured pretty much equally as the Medusa one, i wanted to try if it was only a Medusa problem or something more

#

Laravel is exposed on port 80

#

Maybe i'm just missing something in the Docker network configuration

turbid raven
#

and the network in your compose is set to the name of the network using the bridge driver?

finite parcel
#

Yes exactly

#

All containers use only the store-bridge network

#

Which is created using docker network create -d bridge store-bridge

turbid raven
#

in you compose file, do you have something like

networks:
  mynetwork:
    driver: bridge
#

and then for the different service

networks:
      - mynetwork
finite parcel
#

Yep exactly

turbid raven
#

hum 🤔

finite parcel
#

I'm getting a big headache from this thing haha

finite parcel
#

Update: i tried it on an Intel machine (i forgot to mention i have an M1 macbook) and it is working with the exact same setup i have right now. Guess it's a M1 related problem