MyClawTrade

Setup pain

Binance API 401 and IP allowlist errors

A 401 right after deploy is almost never “the strategy.” It is the key, the IP lock, or the clock. Work the list in order. Do not turn withdraw on to “test.”

Never enable withdrawals to debug auth. A 401 is an auth problem. Withdraw permission cannot fix it and can empty the account if the key leaks.

What 401 is telling you

The exchange did not accept the request as signed by a key it likes from this IP. Spot vs futures mismatch can look similar. Read the JSON body, not only the HTTP code.

Check the IP first

curl -s https://api.ipify.org && echo
# that IPv4 must be the only IP on the Binance key allowlist

Rebuilds change the droplet IP. The old allowlist then 401s every call. Update the key to the new IPv4. Do not set “unrestricted” for a minute.

Key and secret

  1. Confirm BINANCE_API_KEY and BINANCE_API_SECRET in .env — no quotes, no trailing space.
  2. chmod 600 .env
  3. systemd EnvironmentFile= must point at that file.
  4. If you rotated the key on Binance, the old secret in .env is dead. Replace both.

Clock

timedatectl
sudo timedatectl set-ntp true

Binance rejects signed requests when the VPS clock is too far off. NTP on Ubuntu usually fixes -1021 recvWindow errors that people misread as 401.

Still failing?

Get the full walkthrough

The paid guide includes the source, config template, and deploy script. 50% off: $19.99 (was $39.99). One-time.

Get the ebook — $19.99

Educational product. Trading can lose money. Not financial advice.

Keep reading

How to run an OpenClaw trading bot on a $5 VPSDIY setup Binance API keys for a bot (safely)Setup systemd and journalctl for a Python trading botOps errors