Docker SSL working on container but not accessible in host?

Currently I have laravel project on my docker instance.

But the problem is,

SSL accessible only for that container and I can check it using this command

curl --insecure https://127.0.0.1:4021/api/login

And this gives me my api response like this

{"success":0,"message":"405: Method is not allowed for the requested route"}

Which is correct and working fine only if I try to curl it inside the container.

Now I’m trying to check if that curl is accessible to my docker host

using this command

curl -k -v https://MY-HOST-DOCKER-IP:4021/api/login

but this gives me an error like this

image

What could be the reason why this error keeps showing?

Please share the exact command or docker-compose.yml you used to create your container.