# POST request returns 502 Bad Gateway intermittently

**URL:** <https://discourse.nodered.org/t/post-request-returns-502-bad-gateway-intermittently/7200>\
**Category:** General\
**Created:** [24 January 2019 08:54 UTC](https://discourse.nodered.org/t/post-request-returns-502-bad-gateway-intermittently/7200 "2019-01-24T08:54:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![piptan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/piptan/32/5345_2.png) [@piptan](https://discourse.nodered.org/u/piptan)\
**Post date:** [24 January 2019 08:54 UTC](https://discourse.nodered.org/t/post-request-returns-502-bad-gateway-intermittently/7200/1 "2019-01-24T08:54:50Z")

</div>

Even when I tried to Deploy my application via Node-RED, it somtimes got 502 error.

I just create very simple node-red application for testing purpose. It just receives GET and POST request with on parameter and returns basic html response that shows that parameter.

For GET, you can test it at [https://testpost502.mybluemix.net/testget?id=1234](https://testpost502.mybluemix.net/testget?id=1234).

For POST, you can call it at [https://testpost502.mybluemix.net/testpost?id=1234](https://testpost502.mybluemix.net/testpost?id=1234).

It seems that for GET, it will not fail at all but for POST, it will fail with 502 error once every 10-20 calls or more. So, it may be POST that can cause this error (and yes, if deploy on Node-RED use POST, it will be affected).

Something is getting wrong with my node.js I guess.

[  
{  
"id": "6409895d.6fc088",  
"type": "tab",  
"label": "Flow 1",  
"disabled": false,  
"info": ""  
},  
{  
"id": "802d4488.288318",  
"type": "http in",  
"z": "6409895d.6fc088",  
"name": "",  
"url": "/testpost",  
"method": "post",  
"upload": false,  
"swaggerDoc": "",  
"x": 150,  
"y": 200,  
"wires": [  
[  
"ab121371.9c37f",  
"f43e7ab8.016478"  
]  
]  
},  
{  
"id": "ab121371.9c37f",  
"type": "template",  
"z": "6409895d.6fc088",  
"name": "done",  
"field": "payload",  
"fieldType": "msg",  
"format": "handlebars",  
"syntax": "mustache",  
"template": "\n\n \n \n Test\n \n \n \n id={{payload.id}}\n \n",  
"output": "str",  
"x": 370,  
"y": 200,  
"wires": [  
[  
"8bfa16.c191b5e8"  
]  
]  
},  
{  
"id": "8bfa16.c191b5e8",  
"type": "http response",  
"z": "6409895d.6fc088",  
"name": "",  
"statusCode": "",  
"headers": {},  
"x": 560,  
"y": 200,  
"wires": []  
},  
{  
"id": "f43e7ab8.016478",  
"type": "debug",  
"z": "6409895d.6fc088",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "true",  
"x": 270,  
"y": 120,  
"wires": []  
},  
{  
"id": "c799ce9.f96a93",  
"type": "http in",  
"z": "6409895d.6fc088",  
"name": "",  
"url": "/testget",  
"method": "get",  
"upload": false,  
"swaggerDoc": "",  
"x": 130,  
"y": 360,  
"wires": [  
[  
"3b6f9c43.9777c4",  
"70c62290.2fad1c"  
]  
]  
},  
{  
"id": "3b6f9c43.9777c4",  
"type": "template",  
"z": "6409895d.6fc088",  
"name": "done",  
"field": "payload",  
"fieldType": "msg",  
"format": "handlebars",  
"syntax": "mustache",  
"template": "\n\n \n \n Test\n \n \n \n id={{req.query.id}}\n \n",  
"output": "str",  
"x": 360,  
"y": 360,  
"wires": [  
[  
"58df9427.933eac"  
]  
]  
},  
{  
"id": "70c62290.2fad1c",  
"type": "debug",  
"z": "6409895d.6fc088",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "true",  
"x": 260,  
"y": 280,  
"wires": []  
},  
{  
"id": "58df9427.933eac",  
"type": "http response",  
"z": "6409895d.6fc088",  
"name": "",  
"statusCode": "",  
"headers": {},  
"x": 550,  
"y": 360,  
"wires": []  
}  
]

---

<div class="post-metadata">

**Author:** ![piptan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/piptan/32/5345_2.png) [@piptan](https://discourse.nodered.org/u/piptan)\
**Post date:** [12 February 2019 08:52 UTC](https://discourse.nodered.org/t/post-request-returns-502-bad-gateway-intermittently/7200/2 "2019-02-12T08:52:01Z")

</div>

I contacted IBM Cloud Support team. They found stale route issue and had me restage my application. It worked OK since then.
