axios icon indicating copy to clipboard operation
axios copied to clipboard

Always request failed with status code 503 in node environment

Open Hexi1997 opened this issue 2 years ago • 8 comments

Describe the bug

It's a very strange bug, I can't use axios in node environment on my deepin system, but it works fine in windows and mac.

{"message":"Request failed with status code 503","name":"Error","stack":"Error: Request failed with status code 503\n at createError (/home/hexi/Learn/nodejs-axios/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/home/hexi/Learn/nodejs-axios/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/home/hexi/Learn/nodejs-axios/node_modules/axios/lib/adapters/http.js:270:11)\n at IncomingMessage.emit (node:events:525:35)\n at endReadableNT (node:internal/streams/readable:1359:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"url":"https://alpha-testnet.api.matrixmarket.xyz/mart/v2/api-docs","headers":{"Accept":"application/json, text/plain, /","User-Agent":"Mozilla","Content-Type":"application/json","host":"alpha-testnet.api.matrixmarket.xyz"},"transformRequest":[null],"transformResponse":[null],"timeout":0,"withCredentials":true,"responseType":"text","xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"method":"get"}}

To Reproduce

This is a minimal reproduction repository

https://github.com/Hexi1997/nodejs-axios

Code snippet

const axios = require('axios').default

axios({url:'https://alpha-testnet.api.matrixmarket.xyz/mart/v2/api-docs',responseType:'text',withCredentials:true,headers:{ "User-Agent": "Mozilla","Content-Type": "application/json"}}).then(v=>{console.log(v)}).catch((e)=>console.log(JSON.stringify(e)));

Expected behavior

fetch data succeed!

Axios Version

0.21.2

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

18.12.0

OS

deepin community 20.2.2

Additional Library Versions

No response

Additional context/Screenshots

No response

Hexi1997 avatar Nov 01 '22 03:11 Hexi1997

I had this same issue and it was caused by me changing my npm config proxy for npm install. I resolved it by resetting the proxy after npm install.

willywanka75 avatar Mar 08 '23 19:03 willywanka75

I had this same issue and it was caused by me changing my npm config proxy for npm install. I resolved it by resetting the proxy after npm install.

I have tried as you say, still no

Hexi1997 avatar Mar 09 '23 03:03 Hexi1997

I had the same issue, AxiosError: Request failed with status code 503 My npm command is trying to reach distant server.

NizareDam avatar Feb 20 '24 14:02 NizareDam

I have same issue

burhon97 avatar Apr 02 '24 13:04 burhon97

Get 503 with axios behind a proxy server, while node-fetch works fine. F* axios

barwalker avatar Apr 10 '24 09:04 barwalker

I finally solved the issue, it was for sure a proxy issue.

    - npm config set noproxy ".<your_domain>.net"
    - npm config get proxy
    - npm config set proxy ""
    - export http_proxy=""
    - export https_proxy=""
    - export HTTP_PROXY=""
    - export HTTPS_PROXY=""
    - export no_proxy=""

You can try setting this configuration first. I hope it will help you.

NizareDam avatar Apr 10 '24 12:04 NizareDam

I have same issue

takhello avatar Aug 08 '24 08:08 takhello

I have same issue, I need an agent。

takhello avatar Aug 08 '24 08:08 takhello