question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always get 403 forbidden when use await mexc.loadMarkets()

See original GitHub issue

When I’m going to load all the markets from below, I will always the the error below even if I tried to change my IP address, but it will success last week, and now I can even runs well using command line on Terminal: curl https://www.mexc.com/open/api/v2/market/coin/list

  • OS: MACOS/ LINUX
  • Programming Language version: nodejs 18.02
  • CCXT version: latest
export const exchangeArray = [
    {name: "kraken", exchange: kraken},
    {name: "bitfinex", exchange: bitfinex},
    {name: "huobipro", exchange: huobipro},
    {name: "okex", exchange: okex},
    {name: "mexc", exchange: mexc},
    {name: "binance", exchange: binance},
    {name: "kucoin", exchange: kucoin},
    // {name: "gateio", exchange: geteio}
]


export const loadExchanges = async () => {
    let promises = [];
    for (let i = 0; i < exchangeArray.length; i++) {
        promises.push(exchangeArray[i].exchange.loadMarkets())
    }
    await Promise.all(promises)
    return "success"

}
ExchangeNotAvailable: mexc GET https://www.mexc.com/open/api/v2/market/coin/list 403 Forbidden <HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
 
You don't have permission to access "http&#58;&#47;&#47;www&#46;mexc&#46;com&#47;open&#47;api&#47;v2&#47;market&#47;coin&#47;list" on this server.<P>
Reference&#32;&#35;18&#46;1fcbdc17&#46;1669729350&#46;8cdc15
</BODY>
</HTML>

    at mexc.handleHttpStatusCode (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/Exchange.js:753:19)
    at /Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/Exchange.js:600:22
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async timeout (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/functions/time.js:181:20)
    at async mexc.fetch2 (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/Exchange.js:1901:16)
    at async mexc.request (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/Exchange.js:1905:16)
    at async mexc.fetchCurrencies (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/mexc.js:408:26)
    at async mexc.loadMarketsHelper (/Users/amandachadwick/PycharmProjects/freelancer/0_mine/node_modules/ccxt/js/base/Exchange.js:624:26)
    at async Promise.all (index 4)
    at async loadExchanges (file:///Users/amandachadwick/PycharmProjects/freelancer/0_mine/cex/cex.js:32:5) {
  constructor: [class ExchangeNotAvailable extends NetworkError]
}

Node.js v18.12.1



Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nilswxcommented, Dec 6, 2022

On my machine, curl works but fetch only works in the browser - not on Node.js (v19).

It’s not the IP, or the request content/headers, nor the User-Agent. Akamai is fingerprinting and blocking these HTTPS requests to MEXC based on your TLS ciphers. Explanation here, but I agree that MEXC should fix this.

Until then, just reorder your TLS ciphers at the start of your program. Fixed it for me.

const tls = require('tls');
tls.DEFAULT_CIPHERS = 'TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES256-GCM-SHA384';
tls.DEFAULT_MIN_VERSION = 'TLSv1.2';
fetch('https://www.mexc.com/open/api/v2/market/coin/list')
  .then(res => res.json())
  .then(console.log); // Works now!
0reactions
ttoduacommented, Dec 8, 2022

issue has been fixed by mexc API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is the 403 Forbidden Error and How to Fix It (8 Methods ...
403 Forbidden – you don't have permission to access this resource is an HTTP status code that occurs when the web server understands...
Read more >
How to Fix the 403 Forbidden Error (2 Methods That Work)
The 403 forbidden error can bar access to a website. In this post, we'll show you a few easy ways to fix this...
Read more >
403 Forbidden error: What it is and how to fix it - Allconnect.com
Status code 403; Access denied. Before we jump into how to solve the issue, let's explore why you're getting the message in the...
Read more >
HTTP 403: Forbidden error when starting jupyterhub #1377
Hi, I have been trying to use jupyterhub for a while now but I am struggling with a 403 error which I cannot...
Read more >
How to Fix a 403 Forbidden Error on Your WordPress Site
The 403 Forbidden error indicates that the server understood the request but refuses to authorize it. Find out more about the causes and...
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