Nodejs/ Nginx server(AWS)/ Mysql/ insert 502 Bad Gateway error
<p>When I try to insert some text with Mysql, AWS ElasticBeanstalk Nginx server,</p>

<p>It sometimes come out the error message that 502 Bad Gateway.</p>

<p>Only insert case is error(select, update, delete are working very well.)</p>

<p>If I try to insert in localhost, It's working very well.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="/finance" method="post"&gt;
 &lt;div class="input-field col l12"&gt;
  &lt;input name="consult_name" type="text"&gt;
  &lt;input type="submit" value="send"&gt; 
 &lt;/div&gt;
&lt;/form&gt;</code></pre>
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>router.post('/finance', function(req, res, next) {
 var consult_name = req.body.consult_name;
 console.log(consult_name);
 
 
 var sets = {consult_name : consult_name};
 
 mysql.insert('insert into cider.cid_finance set ?', sets,  function (err, data){

 res.redirect('/finance');
 });
});</code></pre>
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>2016/08/30 22:04:24 [error] 29838#0: *52 upstream prematurely closed connection while reading response header from upstream, client: 115.95.162.173, server: , request: "POST /finance HTTP/1.1", upstream: "http://127.0.0.1:8081/finance", host: "cidermics.com", referrer: "http://cidermics.com/finance"
2016/08/30 22:04:24 [error] 29838#0: *52 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 115.95.162.173, server: , request: "POST /finance HTTP/1.1", upstream: "http://127.0.0.1:8081/finance", host: "cidermics.com", referrer: "http://cidermics.com/finance"</code></pre>
</div>
</div>
</p>

<p>AWS ElasticBeanstalk error log</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>/var/app/current/node_modules/mysql/lib/protocol/Parser.js:77
        throw err; // Rethrow non-MySQL errors
        ^

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
    at Query.Sequence._packetToError (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:48:14)
    at Query.ErrorPacket (/var/app/current/node_modules/mysql/lib/protocol/sequences/Query.js:83:18)
    at Protocol._parsePacket (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:280:23)
    at Parser.write (/var/app/current/node_modules/mysql/lib/protocol/Parser.js:73:12)
    at Protocol.write (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.&lt;anonymous&gt; (/var/app/current/node_modules/mysql/lib/Connection.js:98:28)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)</code></pre>
</div>
</div>
</p>