V0.16: to delete blocked IP and add allow IP with stalwart-cli command line

Recently, I can’t access Stalwart admin page. After checking the log file, I found Stalwart somehow blocked my Newt container IP (127.18.0.3) at port 8080 (I use Pangolin on another server as its reversed proxy).

This is the way I’ve solved the problem without downtime.

I use stalwart-cli command so that I don’t need to spin up Stalwart in recovery mode; thus no downtime.

The stalwart-cli command was installed earlier during the migration steps (from 0.15–>0.16).

In case you have created an APIKEY for your admin account, use following commands:
To list blocked IPs
stalwart-cli --url https://stalwart.yourdomain.com --api-key API_AAAABxxxxxxxT9OtxA query BlockedIp
To delete one blocked IP
stalwart-cli --url https://stalwart.yourdomain.com --api-key API_AAAABxxxxxxxT9OtxA delete BlockedIp --ids iq7voy2cabqa

To add allowed IPs (see schema reference here: https://stalw.art/docs/ref/ )
stalwart-cli --url https://stalwart.yourdomain.com --api-key API_AAAABxxxxxxxT9OtxA create AllowedIp --field address='127.18.0.0/16' --field reason='allow newt container ip' --field createdAt='2026-05-15T11:00:00+07:00'
adding --field expiresAt=‘…’ to the command, if required; otherwise, no expiry date

In case you haven’t created an APIKEY before, you may specify user and password instead of the apikey, for example,
stalwart-cli --url https://stalwart.yourdomain.com --user admin --password 12345678 query BlockedIp

Hope this is useful for anyone who will experience the same issue.

3 Likes

Thanks for noting the Stalwart version because previous versions of the stalwart-cli had a different syntax for finding blocked IPs.

I had the same issue but I did this instead:

enciphered@enciphered-home:\~/docker/mail$ docker exec -i stalwart curl -X POST http://127.0.0.1:8080/jmap   -u "admin:VerySecurePasswordObviouslyHere"   -H "Content-Type: application/json"   -d '{

      "using": \[

        "urn:ietf:params:jmap:core",

        "urn:stalwart:jmap"

      \],

      "methodCalls": \[

        \[

          "x:AllowedIp/set",

          {

            "create": {

              "docker-net": {

                "address": "172.24.0.0/16"

              }

            }

          },

          "c1"

        \]

      \]

    }'