# I am getting Error: read ECONNRESET

**URL:** <https://community.postman.com/t/i-am-getting-error-read-econnreset/38977>\
**Category:** Help Hub\
**Tags:** postman\
**Created:** [September 9, 2022, 5:19am UTC](https://community.postman.com/t/i-am-getting-error-read-econnreset/38977 "2022-09-09T05:19:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit-mishra](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@mohit-mishra](https://community.postman.com/u/mohit-mishra)\
**Post date:** [September 9, 2022, 5:19am UTC](https://community.postman.com/t/i-am-getting-error-read-econnreset/38977/1 "2022-09-09T05:19:06Z")

</div>

_My question_: Why i am getting this issue?

_Details (like screenshots)_:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/1/17cbd52886ae6121ed5c0e82a9088af4bd7f85ad.png)

_How I found the problem_:

I have also written my router.js file code for clear understanding.

```auto
const express = require('express');

const router = express.Router();

// GET ALL API
router.get('/getAll', (req , res) => {
    res.send('Gettting All The Data')
})

// GET By ID API
router.get('/getOne/:id', (req , res) => {
    res.send("ID : ${req.params.id}")
})

// POST API
router.post('/post', (req , res) => {
    res.send('POST Method')
})

// PUT API
router.put('/put', (req , res) => {
    res.send('PUT METHOD')
})

//DELETE API
router.delete('/delete', (req , res) => {
    res.send('DELETE Method')
})

module.exports = router;

```

_I’ve already tried_:

- ALready tried all the method available online

---

<div class="post-metadata">

**Author:** ![ianthepostmanaut](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/ianthepostmanaut/32/11109_2.png) [@ianthepostmanaut](https://community.postman.com/u/ianthepostmanaut)\
**Post date:** [September 9, 2022, 6:23pm UTC](https://community.postman.com/t/i-am-getting-error-read-econnreset/38977/2 "2022-09-09T18:23:45Z")

</div>

This happens when the server closes the TCP/IP connection before the client receives a response.

Where in your code do you specify the `/api/` path prefix on your endpoints? Your screenshot of the console error indicates `localhost/api/put` for example. Is there more code below the Node/Express code that you’ve shared that adds that as a path prefix? Can you also include that please?

---

<div class="post-metadata">

**Author:** ![mohit-mishra](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@mohit-mishra](https://community.postman.com/u/mohit-mishra)\
**Post date:** [September 10, 2022, 5:18am UTC](https://community.postman.com/t/i-am-getting-error-read-econnreset/38977/3 "2022-09-10T05:18:44Z")

</div>

> [@ianthepostmanaut](#):
>
> e

No haven’t added more code till now. I only have 2 files containing code index.js and routes.js. I have already shared routes.js code and wait I will share index.js code also

```auto
require('dotenv').config()

const express = require('express')
const mongoose = require('mongoose')
const mongoData = process.env.DATABASE_URL;
// Let's connect to our MongoDB Atlas Database
mongoose.connect(mongoData , {useNewUrlParser: true})
const database = mongoose.connection;

database.on('error' , (error) => {
    console.log(error)
})

database.once('connected' , () =>{
    console.log('Database Connected')
})

// This will be the app that we will be using for the routing of our different endpoints
const app = express();

app.use(express.json)

const routers = require('./routes/routes')

// So all our end points will start from the address /api
app.use('/api' , routers)

app.listen(4000, () => {
    console.log('Server Started at ${4000}')
})

```

The code above written is of index.js which is my project main file. But still after all try I am not able to get anything out of it.

---

<div class="post-metadata">

**Author:** ![ianthepostmanaut](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/ianthepostmanaut/32/11109_2.png) [@ianthepostmanaut](https://community.postman.com/u/ianthepostmanaut)\
**Post date:** [September 10, 2022, 6:32am UTC](https://community.postman.com/t/i-am-getting-error-read-econnreset/38977/4 "2022-09-10T06:32:08Z")

</div>

Thanks for sending over that other code. I’d suggest putting more console logging in your source to trace what’s happening, or look at some debuggers to help from there.

I truly hate to be the “it works on my machine” guy, but I put together a quick node/express app based on what you sent, and I can access localhost:4000 without getting that error (running Postman desktop app on Windows 11, accessing localhost:4000 on a WSL2 instance running the Node app)

> **[GitHub - iandouglas/node-express-example: example node/express API router](https://github.com/iandouglas/node-express-example)**
>
> example node/express API router. Contribute to iandouglas/node-express-example development by creating an account on GitHub.

I wondered if it was a CORS issue, but that didn’t matter in my example code. Without more debugging on your side, I can’t really diagnose further what the problem is.
