title: Error: connect ECONNREFUSED 127.0.0.1:5000
body: <p>I´ve the file <strong>cases.js</strong> to create the route I want:</p>
  
  <pre><code>const express = require("express");
  const { requireSignin } = require("../controllers/auth");
  const { getCases } = require("../controllers/cases");
  const { scrapingData } = require("../scrapingData");
  const router = express.Router();
  
  router.get("/cases", requireSignin, scrapingData, getCases);
  
  module.exports = router;
  </code></pre>
  
  <p>requireSignin from <strong>controllers/auth</strong> looks like this:</p>
  
  <pre><code>exports.requireSignin = expressJwt({
    secret: process.env.JWT_SECRET,
    userProperty: "auth",
  });
  </code></pre>
  
  <p><strong>scrapingData</strong> as middleware I have: </p>
  
  <pre><code>const updateMongoRecords = async () =&gt; {
    mongoose.Promise = global.Promise;
    mongoose.set("debug", true);
  
    Case.deleteMany({}, (err, result) =&gt; {
      if (err) {
        console.log(err);
      } else {
        console.log("Successfully deleted all records");
      }
    });
  
    const dataPath = Path.join(__dirname, "files", "covid-data.csv");
  
    try {
      let headers = Object.keys(Case.schema.paths).filter(
        (k) =&gt; ["_id", "__v"].indexOf(k) === -1
      );
  
      await new Promise((resolve, reject) =&gt; {
        let buffer = [],
          counter = 0;
  
        let stream = fs
          .createReadStream(dataPath)
          .pipe(csv())
          .on("error", reject)
          .on("data", async (doc) =&gt; {
            stream.pause();
            buffer.push(doc);
            counter++;
            // log(doc);
            try {
              if (counter &gt; 10000) {
                await Case.insertMany(buffer);
                buffer = [];
                counter = 0;
              }
            } catch (e) {
              stream.destroy(e);
            }
            stream.resume();
          })
          .on("end", async () =&gt; {
            try {
              if (counter &gt; 0) {
                await Case.insertMany(buffer);
                buffer = [];
                counter = 0;
                resolve();
              } 
            } catch (e) {
              stream.destroy(e);
            }
          });
      });
    } catch (e) {
      console.error(e);
    } finally {
      process.exit();
    }
  };
  
  exports.scrapingData = async (req, res, next) =&gt; {
     const url = "https://covid.ourworldindata.org/data/owid-covid-data.csv";
     const path = Path.resolve(__dirname, "files", "covid-data.csv");
  
     const response = await Axios({
       method: "GET",
       url: url,
       responseType: "stream",
      });
  
     response.data.pipe(fs.createWriteStream(path));
  
     return new Promise((resolve, reject) =&gt; {
     response.data.on("end", () =&gt; {
       resolve(updateMongoRecords());
       next();
     });
  
     response.data.on("error", (err) =&gt; {
       reject(err);
     });
    });
   };
  </code></pre>
  
  <p>And  getCases.js inside <strong>controllers/cases</strong>  I have:</p>
  
  <pre><code>const Case = require("../models/case");
  
  exports.getCases = async (req, res) =&gt; {
     const cases = await Case.find().then((cases) =&gt; res.json(cases));
  };
  </code></pre>
  
  <p>With this code I am able to fetch in the route /cases all the cases in the client side (like postman) and it shows all of them. But the problem is that I can´t make any other requests (like signing out, which works fine if I don´t make the get request for the cases like before) afterwards because client (postman) gives the error: GET <a href="http://localhost:5000/signout" rel="nofollow noreferrer">http://localhost:5000/signout</a>
  Error: connect ECONNREFUSED 127.0.0.1:5000</p>
  
  <p>in case you want to see the code for signout is like this:</p>
  
  <pre><code>const express = require("express");
  const { signup, signin, signout } = require("../controllers/auth");
  const router = express.Router();
  router.post("/signup", userSignupValidator, signup);
  router.post("/signin", userSigninValidator, signin);
  router.get("/signout", signout);
  </code></pre>
  
  <p>inside <strong>controllers/auth.js</strong>:</p>
  
  <pre><code>exports.signout = (req, res) =&gt; {
    res.clearCookie("t");
    return res.json({ message: "Signout successfully done" });
  };
  </code></pre>
  
  <p>Any help on this??</p>