Tickmark exchange reliability, measured
Guides Published 2026-11-07 8 min read

Binance error -1021 timestamp: causes and how to fix it

Binance API error -1021 INVALID_TIMESTAMP means the timestamp on your signed request falls outside the window Binance will accept. The message usually reads "Timestamp for this request is outside of the recvWindow" or "was 1000ms ahead of the server's time". In most cases your own clock is the cause, so the fix is to synchronise it, measure the offset against Binance's server time, and handle any remaining network delay properly. A larger recvWindow can hide the problem, but it should not be your first move.

Short answer

Synchronise your machine's clock with a time service, then compare it with Binance's server time. Binance accepts a request when the timestamp is less than 1,000 ms ahead of its server time and no more than recvWindow behind it. The default recvWindow is 5,000 ms.

What the error means

Binance requires a timestamp parameter on signed endpoints, meaning requests that touch your account: placing an order or reading balances. It should be the time in milliseconds at which the request was created. Binance uses it to reject stale or replayed requests, so a captured request cannot simply be resent later.

The check is written out in Binance's documentation:

if (timestamp < serverTime + 1000 && serverTime - timestamp <= recvWindow) { process } else { reject }

Read that as two separate limits, and notice which message goes with which.

  • Too far ahead: if your timestamp is 1,000 ms or more ahead of Binance's clock, you get "Timestamp for this request was 1000ms ahead of the server's time". Your clock is running fast.
  • Too far behind: if your timestamp is older than recvWindow when Binance processes it, you get "Timestamp for this request is outside of the recvWindow". Your clock is slow, or the request took too long to arrive.

The two limits are not equal. You have 5,000 ms of tolerance on the slow side by default, but only 1,000 ms on the fast side, and raising recvWindow does nothing for the fast side.

Binance API documentation error codes page showing -1021 INVALID_TIMESTAMP with two messages about the recvWindow and being 1000ms ahead of server time
The -1021 entry in Binance's error code documentation, with both messages. The message you received tells you which direction your clock is off. developers.binance.com · 2026-11-07

Step 1: measure the offset

Do not guess. Fetch the server time and compare it to your own clock. The public endpoint needs no key. For USD-margined futures it is https://fapi.binance.com/fapi/v1/time, and for spot it is https://api.binance.com/api/v3/time.

A small Python check looks like this:

import time, requests; t0 = time.time()*1000; s = requests.get("https://fapi.binance.com/fapi/v1/time").json()["serverTime"]; t1 = time.time()*1000; print("offset ms:", s - (t0 + t1) / 2, "round trip ms:", t1 - t0)

This uses the midpoint of the round trip as your best estimate of when the server read its clock. Run it a few times. A positive offset means Binance's clock is ahead of yours, so your clock is slow. A negative offset means yours is fast. If the round trip is large or varies a lot, your network is part of the problem. Our guide to clock offset explains this method and its limits.

Step 2: synchronise your clock

If the offset is more than a few hundred milliseconds, fix your clock first. That solves most cases.

  • Linux: check with timedatectl. Install and enable chrony if no service is synchronising, then use chronyc makestep to correct a large offset at once.
  • Windows: open Date and Time settings and use "Sync now". Windows' default synchronisation is infrequent, so a machine can drift between runs. Consider configuring a more frequent time service.
  • macOS: turn on "Set time and date automatically" in Date and Time settings.
  • Docker: a container uses the host's clock, so fix the host. On Docker Desktop, the internal virtual machine can drift after your laptop sleeps, and restarting it often clears the error.
  • Virtual machines and cloud servers: a paused or migrated machine can come back with an old time. Run a time service inside it.

The NTP Pool's documentation describes setting up public time servers if your system does not have a default configured, though most cloud providers offer their own internal time service, which is usually the better choice.

Step 3: generate the timestamp at the right moment

A correct clock can still produce this error if your code creates the timestamp too early. Check for these causes:

  • The timestamp is created long before sending. Create it immediately before signing and sending. If your request passes through a queue or a slow thread, the timestamp ages while it waits.
  • A retry loop reuses a request. A retried request needs a new timestamp and a new signature, otherwise it will fail with this error after several attempts.
  • The wrong unit. Binance expects milliseconds. A timestamp in seconds has ten digits rather than thirteen and will be far outside the window.
  • Rate limiting by your own client. A client-side throttle that holds a signed request for several seconds will age it out of the window.
  • A heavily loaded machine. When the CPU is saturated, delays between timestamp and send can be surprisingly long.

Step 4: use a time offset in your client if you must

A common approach is to fetch the server time at startup, calculate the difference from your own clock, and add it to every timestamp. Many client libraries offer this as an option, such as one that adjusts for time difference automatically.

This is useful where you cannot control the system clock, but it has a weakness: the offset goes out of date as your clock keeps drifting. If you use this approach, refresh it regularly and handle the error by refreshing once before retrying. Fixing the system clock is the better long-term solution, since all your software benefits from it.

Step 5: think carefully about recvWindow

recvWindow is the number of milliseconds after timestamp that the request stays valid. It defaults to 5,000. Binance's documentation describes it as a way to say that a request must be processed within a certain time or be rejected, which is a safety feature rather than a nuisance. Increasing it may stop the errors, but consider what it means. It tells Binance you are happy for an order created several seconds ago to be executed now. In a fast market, a trade you decided on 30 seconds ago may be a very different trade today.

A large window also masks the real issue, whether that is a drifting clock or an unreliable network. It does not help at all if your clock is fast, because the 1,000 ms limit is separate. Increase it only moderately, only as a stopgap and only once you have measured what is going on. If you find you need a large window, the real problem is elsewhere.

When the problem is the network or Binance

If your clock is correct and timestamps are created at the right moment, look at the path. High latency, packet loss or a congested proxy can make requests take long enough to fall outside the window. The round-trip time from Step 1 will show this. Binance's API also sits behind infrastructure of its own, so short-lived delays are possible at busy times.

Occasional, isolated errors are usually harmless if you handle them by rebuilding and resending the request. A sudden burst across many machines that were previously fine points to the network or the exchange. Compare with our readings for Binance, including its recent clock offset and response times, and check its announcements. Our data shows Binance's public API only as seen from our location, though.

Handling it in code

A robust client treats -1021 as a known, recoverable condition rather than a generic failure.

  • Recreate, do not resend. Build a new request with a new timestamp and signature.
  • Check before retrying an order. The rejection means this specific request was not processed, but if your earlier attempts had other errors, query the order status first so you do not double up. Use a unique client order ID so a duplicate can be detected.
  • Limit retries. Retrying in a tight loop can lead you into rate limits, and our rate limit guide explains the consequences.
  • Log the offset and the round trip. When this error recurs, a log tells you at once whether your clock has drifted or the network has worsened.
  • Alert on it. A rising rate of -1021 is an early warning that a machine's clock is going wrong.

Do other exchanges have the same error?

Yes. Any exchange using signed requests has some version of this check, under a different code and with a different window. Bybit, for instance, has a timestamp check against its own server time and a recv_window parameter, and OKX requires a timestamp in its request headers. The advice is the same, but read each exchange's documentation for the exact limits.

Common questions about error -1021

Why does it work on my laptop and fail on my server, or the reverse?

Because each machine has its own clock and route to Binance. Run the offset check on both. Cloud servers normally have good time, while laptops that sleep often do not.

Why did the error start suddenly when nothing changed?

Clocks drift slowly. An offset can grow for weeks until it crosses the limit. A system update can also disable a time service, and a change to a new network can raise latency.

Is it safe to set recvWindow to its maximum?

It stops many errors, but it means Binance may execute a request that is far older than you intended, in a market that may have moved. We would treat it as a temporary measure at most.

Fix it in this order

  1. Read which of the two messages you received.
  2. Measure your offset against Binance's server time.
  3. Synchronise your system clock and confirm it stays synchronised.
  4. Create the timestamp immediately before signing and sending.
  5. Make sure retries rebuild the timestamp and signature.
  6. Only then consider a moderate change to recvWindow.

Related reading: Clock offset and stale quotes · Exchange API rate limits and error 429 · Why an exchange API returns 403 or 451

Sources

Binance · Error codes · Binance · General information and timing security · NTP Pool Project · About Tickmark

Other guides

What is a funding rate in crypto perpetual futures? A plain explanation

A funding rate is a regular payment between traders holding opposite sides of a perpetual futures contract. It exists because a perpetual contract never expires, so something else has to keep its price close to the underlying asset. When the rate is positive, longs pay shorts; when it is negative, shorts pay longs. The exchange sets the formula but, on the major exchanges, the money moves between traders.

How to compare funding rates across crypto exchanges: 8h vs 4h settlement

You cannot compare two funding rates by looking at the percentages alone. A rate only means something once you know how often it is charged, whether you are long or short, and whether the two readings describe the same contract at the same moment. The same +0.01% costs twice as much per day on a four-hour schedule as on an eight-hour one, and it earns a short exactly what it costs a long.

What does a negative funding rate mean? Who pays, and what it does not tell you

A negative funding rate means traders holding short positions pay traders holding long positions at the next settlement. It usually happens when a perpetual contract trades below its index price, which often reflects heavy shorting or hedging. It does not mean the price is about to fall or about to rise, and it is not free income for longs, because the price can move against them by far more than the payment.

How to convert a funding rate to APR, and why the number can mislead you

To annualise a funding rate, multiply the rate per settlement by the number of settlements in a day, then by 365. A rate of 0.01% every eight hours becomes 0.01% × 3 × 365 = 10.95% a year. This puts contracts on different schedules onto one scale, which makes them comparable. It does not tell you what you will earn or pay over a year, because it assumes today's rate never changes.

Funding rate arbitrage explained: how it works and what eats the profit

Funding rate arbitrage means holding two offsetting positions in the same asset so that price moves roughly cancel, and collecting funding payments on one side. The classic version buys spot and shorts the perpetual. A second version shorts the perpetual on the exchange with the higher rate and goes long on the exchange with the lower rate. It is often described as risk free. It is not. The risks are simply different from the risk of an ordinary directional trade.

Mark price vs last price vs index price: which one liquidates you?

Perpetual futures show three prices that are easy to mix up. The last price is where the most recent trade happened. The index price is an average of spot prices across several exchanges. The mark price is an exchange's estimate of what the contract is fairly worth, and on the major exchanges it is what decides your unrealised profit and whether you are liquidated. Knowing which price does what explains why a position can be liquidated even though the chart never touched your liquidation level.

How much does a market order really cost? Fees, spread and slippage

The fee on an exchange's fee page is only part of what a market order costs. The rest comes from the price you actually receive, which depends on the direction of your trade, your order size and the depth of the order book at that moment. To compare exchanges fairly, measure the average fill price against one reference price, then add your trading fee on top, and be careful not to count the spread twice.

How to estimate slippage from order book depth before you trade

Slippage is the difference between the price you expected and the average price you actually got. You can estimate most of it before placing an order, because the order book shows how much is available at each price. Add up the levels on the side you will consume until they cover your size, calculate the average price, and compare it with the mid price. The estimate is only as good as the snapshot it came from, and books thin out at the moments you are most likely to need them.

Maker and taker fees explained: how to compare crypto exchange trading fees

A maker adds an order to the book that waits to be filled. A taker fills against an order already there. Most exchanges charge takers more than makers, because makers supply the liquidity others trade against. Comparing exchanges by the headline fee alone is misleading: you need to know which side you usually trade on, what tier your volume actually puts you in, and how the fee compares with slippage and funding on the same trade.

How to check if a crypto exchange is down: a step-by-step guide

When an exchange stops working for you, the first question is whether it is down for everyone or only for you. You can usually answer that in a couple of minutes: check the exchange's own status page, check an independent measurement, try a different network, and test the public API directly. Each source sees something different, so one green page does not prove everything is fine, and one failed request does not prove the exchange is down.

Is an exchange really down? How to read API uptime and outage records

Uptime describes the share of successful requests to particular services, over a particular period, from a particular network route. It does not establish whether you can place an order, withdraw funds or trust an exchange with your assets. A figure like 99.9% is useful only if you know what was tested, from where and for how long, so this guide explains how to read those details on our pages and on anyone else's.

What to do when a crypto exchange goes down while you have an open position

If an exchange stops responding while you hold a position, your first job is to find out what is actually broken, the second is to stop making it worse, and the third is to reduce your risk by whatever route still works. Do not keep resending the same order, because earlier attempts may have gone through. Check the mobile app and the API as alternative routes, consider hedging elsewhere if your exposure is large, and record what happened in case you need to raise it later.

Why exchange APIs reject timestamps: clock offset and stale quotes explained

A fast response can contain an old quote. Round-trip latency, clock offset and quote age describe different parts of a request, and mixing them up can make a clock mismatch look like a delayed market feed. This guide explains each one with a worked example, shows how we estimate them, and covers what to do when an exchange API rejects your request because of the time.

Crypto exchange API rate limits: what error 429 means and how to stay under it

HTTP 429 means you have sent too many requests in a given time, and the server is asking you to slow down. It is not an outage. Each exchange counts requests differently: Binance uses a weight for each endpoint and bans IP addresses that keep going after a 429, Bybit blocks an IP that passes 600 requests in five seconds, and OKX sets limits per endpoint and returns error code 50011. Staying under the limit means reading the response headers, backing off properly and using WebSockets where you can.

Why an exchange API returns 403 or 451: blocks and regions

A 403 means the server understood your request and refuses to carry it out. A 451 means access is refused for legal reasons. On crypto exchange APIs, a 403 can be a web firewall, a request limit, an unauthorised key or a regional block, so the code alone does not tell you which. The response body, the exchange's documentation and a comparison from another network usually do. A real restriction applies to you for a reason, so the right response is to find out whether the service is available where you are.

Before you open a crypto exchange account: a checklist by country

Before you open an account on a crypto exchange, check four things: whether the exchange is allowed to serve people where you live, whether your country's regulator lists it, whether the site in front of you is the real one, and how the exchange has been running lately. The sign-up form takes ten minutes. Recovering from the wrong choice can take months, and sometimes it is not possible at all. This guide works through each check, using Binance and OKX as worked examples because they are the two exchanges readers ask us about most.

How to open and verify a Binance account: a step-by-step guide

Opening a Binance account takes four steps: register with an email address, a phone number or a Google, Apple or Telegram account; complete identity verification; secure the account; and make a first deposit. Registration takes a few minutes. Binance says verification is usually reviewed within 48 hours. This guide follows each step as Binance's own help pages describe it on 8 November 2026, with screenshots of those pages, and points out the details that most often cause trouble later.

How to open and verify an OKX account: a step-by-step guide

Opening an OKX account takes four steps: register with your country of residence, an email address and a phone number; complete identity verification; secure the account; and make a first deposit. OKX says it reviews verification applications within 24 hours. Which OKX company you end up with depends on where you live, and that decides the address you log in at, the fees you pay and the products you see. This guide follows OKX's own help pages as they stood on 8 November 2026, with screenshots, and flags the choices that are hard to undo. OKX shows some help pages differently by region; we read the versions served at okx.com/en-us, and the rules shown in your own account after you log in are the ones that apply to you.