1

I've encountered read ECONNRESET error while I was trying to make a get request through axios.

Configuration is as below:

import express from "express";
import bodyParser from "body-parser";
import axios from "axios";

const app = express();
const port = 3000;

app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: true }));

Get request that I made:

app.get("/", async (req, res) => {
  try {
    const response = await axios.get("https://bored-api.appbrewery.com/random");
  } catch (error) {
    console.error("Failed to make request:", error);
  }
});

However, it turns out to be this error:

Failed to make request: AxiosError: read ECONNRESET
    at AxiosError.from (file:///C:/Users/BENLOW/Desktop/Web%20Development/2023/28.3%20Axios/node_modules/axios/lib/core/AxiosError.js:89:14)
    at RedirectableRequest.handleRequestError (file:///C:/Users/BENLOW/Desktop/Web%20Development/2023/28.3%20Axios/node_modules/axios/lib/adapters/http.js:591:25)
    at RedirectableRequest.emit (node:events:513:28)
    at eventHandlers.<computed> (C:\Users\BENLOW\Desktop\Web Development\2023\28.3 Axios\node_modules\follow-redirects\index.js:14:24)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  syscall: 'read',
  code: 'ECONNRESET',
  errno: -4077,
  ...

Any idea on resolving the error?

  • you do realise your `app.get` makes no response at all, right? – Jaromanda X Aug 20 '23 at 03:59
  • There are a lot of helpful debugging tips [here](https://stackoverflow.com/questions/17245881/how-do-i-debug-error-econnreset-in-node-js/17637900#17637900) – jQueeny Aug 20 '23 at 09:34

0 Answers0