Proxy error: Could not proxy request /api/auth from localhost:3000 to http://localhost:5000/ (ECONNREFUSED) in reactjs

This is app.js file and in useEffect() hook it loads the user.

import React, { useEffect } from "react";
import { Switch, BrowserRouter as Router, Route } from "react-router-dom";
import Landing from "./components/layouts/Landing";
import Header from "./components/layouts/Header";
import store from "./redux/Store";
import setAuthHeader from "./utils/SetAuthHeader";
import { loadUser } from "./redux/auth/AuthActions";
import Routes from "./components/routing/Routes";

const App = () => {
  if (localStorage.getItem("token")) {
    console.log("yes token");
    
    setAuthHeader(localStorage.getItem("token"));
  }

  useEffect(() => {
    console.log("useEffect");
    
    const onStart = true;
    store.dispatch(loadUser(onStart));
  }, [])

  return (
    <Router>
      <Header />
      <Switch>
        <Route exact path="/" component={Landing} />
        <Route component={Routes} />
      </Switch>
    </Router>
  );
};

export default App;

Now this loadUser() method gets called in the useEffect() given in above code.

export const loadUser = (onStart) => async (dispatch) => {
  
  const token = localStorage.getItem("token");
  setAuthHeader(token);
  try { 
    console.log("before get api auth");
           
    const res = await axios.get("/api/auth");
    dispatch({
      type: USER_LOAD,
      payload: res.data
    })
    console.log("user loaded");
    
  } catch (error) {
    console.log(error.response);
    
    if(onStart && onStart !== undefined){
      dispatch({
        type: AUTH_ERROR
      })
      return
    }
    dispatch(setAlert(error.response.data.error, "danger"));
  }
};

This code works perfectly when we manually refresh the page or enter URL in the URL bar. loadUser() function gets called, USER_LOAD request gets dispatched and it sets isAuthenticated: true in the redux store and redirects into the dashboard. Now when I edit some file, then in react page gets reloaded automatically, app loads from the beginning again goes through the same process from the beginning. But the problem this time is when the page gets refreshed on editing some file, again useEffect() function gets called in App.js and then it calls loadUser() function but in loadUser() function,

const res = await axios.get("/api/auth");

This line throws the error saying

Proxy error: Could not proxy request /api/auth from localhost:3000 to http://localhost:5000/ (ECONNREFUSED).

But again if I manually refresh the page or enter URL in the URL bar then, it gets redirected to the dashboard. It happened so, is it because when we type URL and press enter, by default it sends get request and in loadUser also,

const res = await axios.get("/api/auth");

it is sending get request ?. But on editing some file, the page gets refreshed automatically so that it is saying ECONNREFUSED, what request to send.