Action integration error: connection refused

I have this interactive message that includes a button. When it’s clicked, it should send a POST request to http://localhost:3000/mm:

{
    channel_id: chan.id,
    props: {
      attachments: [
        {
          text: 'This is the attachment text.',
          actions: [
            {
              id: 'message',
              name: 'Test',
              integration: {
                url: 'http://127.0.0.1:3000/mm',
                context: {
                  action: 'do_something_ephemeral',
                },
              },
            },
          ],
        },
      ],
    },
  }

It looks like this:

image

But when I click I have this error (and the request is not received by the api)

{
  "id": "api.post.do_action.action_integration.app_error",
  "message": "Action integration error.",
  "detailed_error": "err=Post \"http://127.0.0.1:3000/mm\": dial tcp 127.0.0.1:3000: connect: connection refused",
  "request_id": "qjgh4nz8k7fjix53maxkyoi48y",
  "status_code": 400
}

But when I do a simple curl like curl -XPOST http://localhost:3000/mm, my api received the request.

Note that I’ve modified the untrusted connections and it looks like this

Also my mattermost server is running on localhost. Executed with this command:

docker run --name mattermost-preview -d --publish 8065:8065 mattermost/mattermost-preview

Any hint on this issue?

Solved it: since mattermost is running in a docker container, I needed to add --add-host host.docker.internal:host-gateway to docker run and change the intergration.url by http://host.docker.internal:3000/mm