Home:ALL Converter>Failed to load resource: net::ERR_CONNECTION_REFUSED & TypeError: Failed to fetch

Failed to load resource: net::ERR_CONNECTION_REFUSED & TypeError: Failed to fetch

Ask Time:2022-08-22T22:22:26         Author:jmore

Json Formatter

Have tried everything to connect my React frontend to my express backend (MongoDB). When I run nodemon server and go to URL "http://localhost:5000/api/projects/" I get full json list of data. When I fetch the same link in the frontend I get the errors: Failed to load resource:

net::ERR_CONNECTION_REFUSED** & **TypeError: Failed to fetch.

I've seen this issue linked often but have tried the suggested solutions including checking CORS is enabled and the API link is correct. Neither have worked.

  fetch("https://localhost:5000/api/projects/", {
    method: "GET",
  })
    .then((res) => console.log(res.data))
    .catch((e) => {
      console.error(e)
    })

Author:jmore,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73446673/failed-to-load-resource-neterr-connection-refused-typeerror-failed-to-fetc
yy