Nginx upstream prematurely closed connection while reading response header from upstream, for large requests

前端 未结 9 1026
無奈伤痛
無奈伤痛 2020-12-24 04:27

I am using nginx and node server to serve update requests. I get a gateway timeout when I request an update on large data. I saw this error from the nginx error logs :

<
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 05:24

    I had the same error for quite a while, and here what fixed it for me.

    I simply declared in service that i use what follows:

    Description= Your node service description
    After=network.target
    
    [Service]
    Type=forking
    PIDFile=/tmp/node_pid_name.pid
    Restart=on-failure
    KillSignal=SIGQUIT
    WorkingDirectory=/path/to/node/app/root/directory
    ExecStart=/path/to/node /path/to/server.js
    
    [Install]
    WantedBy=multi-user.target
    

    What should catch your attention here is "After=network.target". I spent days and days looking for fixes on nginx side, while the problem was just that. To be sure, stop running the node service you have, launch the ExecStart command directly and try to reproduce the bug. If it doesn't pop, it just means that your service has a problem. At least this is how i found my answer.

    For everybody else, good luck!

提交回复
热议问题