Binance error: Timestamp for this request was 1000ms ahead of the server's time.

See original GitHub issue

Trying to use Binance, I get this error trying to call fetch_total_balance (probably other methods also but I didn’t test any others yet):

ccxt.base.errors.ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/account?timestamp=1513233650395329&signature=.... 400 {"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}

I already double checked that my system is syncing to internet time. Could it be a timezone handling issue in CCXT?

I found this thread which shows an example using the python-binance library to check the time delay and I don’t see an issue with that library which is why I am guessing it could be a timezone issue in CCXT. When I run:

>>> import time
>>> from binance.client import Client
>>> client = Client(api_key, api_secret)
>>> int(time.time() * 1000) - client.get_server_time()['serverTime']

I consistently get a result around 260ms.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:48 (15 by maintainers)

github_iconTop GitHub Comments

40reactions
kroitorcommented, Jan 29, 2018

@jasonmellone

I just synched my clock

Unfortunately, just synching the clock does not work. You have to set up frequent time synchronization with your system (each 10 minutes). Make sure your timezone is not DST. Unfortunately, without seeing your code and without having the info about your system it’s hard to tell anything exactly. I mean these details: https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue

If that does not help, you can try solutions from this issue: https://github.com/ccxt/ccxt/pull/1477

Namely, for Binance, you can update to most recent version and do this upon instantiation:

import ccxt
b = ccxt.binance({ 'options': { 'adjustForTimeDifference': True }})

It will adjust for the clock unsynchronization itself, but this is less secure.

22reactions
MrRobotXXcommented, May 31, 2019

from control panel > date and time > internet time change the server to >>>> time.nist.gov

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binance order: Timestamp for this request was 1000ms ahead ...
Binance server time is behind your server time, because Binance servers do not sync often with ntp servers. Workaround: binance.
Read more >
get_account error "Timestamp for this request was 1000ms ...
Hey I m trying to do this (on python): a = client.get_acount() print(a) and return me this error "Timestamp for this request was...
Read more >
timestamp for this request was 1000ms ahead of the server's ...
In this video we are fix the time server error when using python binance library.# time server # Binance API #python binanceit is...
Read more >
How to resolve Binance's Timestamp ahead of Server's time ...
"Binance error: Timestamp for this request is 1000ms ahead of the server's time". At first, I thought I made a mistake when typing...
Read more >
Binance API Error Code =-1021 Time Stamp for this ... - Reddit
Timestamp errors in logs happen when the Binance clock gets de-synced from time to time as they can drift apart for a number...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found