# Mailhog ERR_CONNECTION_REFUSED & Could not instantiate mail function

**URL:** https://discourse.roots.io/t/mailhog-err-connection-refused-could-not-instantiate-mail-function/22347
**Category:** trellis
**Tags:** ansible
**Created:** 2022-02-17T16:08:25Z
**Posts:** 12

## Post 1 by @Twansparant — 2022-02-17T16:08:25Z

Hi there,

For some reason **Mailhog** is not working for me in **development**. First time this happens.  
Yes I have **SSL** enabled locally and yes I added the `hsts_max_age` parameter like stated in [the docs](https://docs.roots.io/trellis/master/mail/#development) and re-reprovisioned my local VM.

I also cleared the `hsts` cache in my browser for the domain, but I just keep getting a

```
ERR_CONNECTION_REFUSED
```

error.

Also **Gravityforms** gives me a warning:

```
WordPress was unable to send the notification email. Could not instantiate mail function.
```

So I verified my **sSMTP** credentials on staging and I can send emails from there with these.  
Then I ssh’d into my dev VM and I noticed **sSMTP** is not installed, is this normal behaviour?

What else could be happening?  
Maybe related; this is my first project on my **M1 Macbook Pro** with **Parallels Pro**.

Thanks!

---

## Post 2 by @swalkinshaw — 2022-02-20T16:12:25Z

I think there’s still an unsolved issue about Mailhog on ARM: [Trellis and Apple Silicon · Issue #1253 · roots/trellis · GitHub](https://github.com/roots/trellis/issues/1253#issuecomment-990149540)

I’m going to assume that if you haven’t manually done this workaround, then that’s the first thing to investigate.

---

## Post 3 by @Twansparant — 2022-02-20T19:25:24Z

> [@swalkinshaw](#):
>
> I’m going to assume that if you haven’t manually done this workaround, then that’s the first thing to investigate.

Ah check, did not see that post before!  
Presumably I have to set that here:

> <https://github.com/geerlingguy/ansible-role-mailhog/blob/master/defaults/main.yml#L4>

Thanks!

---

## Post 4 by @swalkinshaw — 2022-02-20T21:05:55Z

Just put these two lines in `group_vars/development/all.yml`:

```
mailhog_binary_url: "https://github.com/evertiro/MailHog/releases/download/v1.0.1-M1/MailHog_linux_arm64"
mhsendmail_binary_url: "https://github.com/evertiro/mhsendmail/releases/download/v0.2.0-M1/mhsendmail_linux_arm64"
```

---

## Post 5 by @Twansparant — 2022-02-21T07:55:50Z

Jup, that was it! I did have to destroy my VM though.  
Thing is, my colleague doesn’t have a M1 chip, so if he would re-provision his VM, Mailhog won’t work for him. Is there a way to add these lines conditionally based upon your `arch`?

---

## Post 6 by @swalkinshaw — 2022-02-23T14:25:03Z

Good question…

Normally you could create files with the architecture name and dynamically include them:

```
- include_vars: "{{ ansible_architecture }}.yml"
```

But since the mailhog role is vendored it makes it harder. Maybe you could just add that `include_vars` at the top in the `dev.yml` playbook.

I know the x86 arch is `x86_64`, you’d have to find what the ARM one is.

---

## Post 7 by @Twansparant — 2022-03-08T18:08:38Z

Thanks, that helped!  
I put this at the top of my `dev.yml`:

```
- hosts: all
  tasks:
    - debug:
        msg: "{{ ansible_architecture }}"
    - name: Include architecture specific ansible vars
      include_vars:
        file: "{{ item }}"
      with_first_found:
        - files:
          - "{{ ansible_architecture }}.yml"
          skip: true
          errors: ignore
```

This will include my local **aarch64.yml** file with my ARM vars:

```
mailhog_binary_url: "https://github.com/evertiro/MailHog/releases/download/v1.0.1-M1/MailHog_linux_arm64"
mhsendmail_binary_url: "https://github.com/evertiro/mhsendmail/releases/download/v0.2.0-M1/mhsendmail_linux_arm64"
```

---

## Post 8 by @SnazzyCreative — 2022-10-15T13:59:28Z

I also encountered this on my M1 mac. I added the above to the top of `dev.yml` and created `aarch64.yml` and added the same two lines to it. Upon reprovisioning, I confirmed that the architecture matched the filename. The script was successful but the connection to mailhog is still refused.

Are there other files I need to touch besides `dev.yml` and `aarch64.yml`?

Thanks!

---

## Post 9 by @ben — 2022-10-15T15:40:46Z

FWIW, after I followed [the Trellis MailHog docs for ARM users](https://docs.roots.io/trellis/master/mail/#development) I had to rebuild my machine in order for MailHog to work

---

## Post 10 by @swalkinshaw — 2022-10-15T17:19:20Z

Trellis will automatically support this soon as well: [Support ARM64 arch in Mailhog role by swalkinshaw · Pull Request #1432 · roots/trellis · GitHub](https://github.com/roots/trellis/pull/1432)

---

## Post 11 by @Twansparant — 2022-10-17T12:35:43Z

No I don’t think so. I do recall the Mailhog port :8025 only works on http and not on a self-signed https domain.

---

## Post 12 by @SnazzyCreative — 2022-11-18T15:02:42Z

I can confirm that after rebuilding the development environment Mailhog was working again on Apple Silicon. Thanks everyone!
