What can I do to fix a 504 gateway timeout error?

后端 未结 3 754
终归单人心
终归单人心 2020-12-10 03:30

I have been using jquery to try and pull data from an API. However I am getting a 504 error. Even when I am using postman to test the data this happens. Can anyone suggest w

相关标签:
3条回答
  • 2020-12-10 04:16

    There is nothing you can do.

    You are sending a request to a server. This particular request fails, because the server sends a request to a proxy, and gets a timeout error. Your server reports this back to you as status 504.

    The only way to fix it is to fix the proxy (make it respond in a timely manner), or to change the server to not rely on that proxy. Both are outside your area.

    You cannot prevent such errors. What you can do is find out what user experience there should be when such a problem happens, and implement it. BTW. If you get 504 errors, then you should also expect timeout errors. Say you make a request to your server with 60 second timeout, and your server makes a request to the proxy with 60 second timeout. Because both timeouts are the same, sometimes your server will receive the proxy timeout and send it to you (status 504), but sometimes your request to the server will time out just before that, and you get a timeout error.

    0 讨论(0)
  • 2020-12-10 04:26

    I recently experienced this issue on one of my app's that was making an ambitious call to it's Firebase Database - it was grabbing a very large record, which took over 60 seconds (the default timeout) to retrieve.

    For those experiencing this error, that have access to their app / site's hosting environment, which is proxying through NGINX, this issue can be fixed by extending the timeout for API requests.

    In your /etc/nginx/sites-available/default or /etc/nginx/nginx.conf add the following variables:

    proxy_connect_timeout       240;
    proxy_send_timeout          240;
    proxy_read_timeout          240;
    send_timeout                240;
    

    Run sudo nginx -t to check the syntax, and then sudo service nginx restart.

    This should effectively quadruple the time before NGINX will timeout your API requests (the default being 60 seconds, our new timeout being 240 seconds).

    Hope this helps!

    0 讨论(0)
  • 2020-12-10 04:34

    One way to fix this is, Changing proxy settings to "NO PROXY" in the browser

    It works in Firefox browser, Others I don't know.

    Follow the steps: 1. Go to preferences (top right corner 3 lines, search in drop down)

    1. Search for proxy (Ctrl+F)

    2. Go inside the settings

    3. select "NO PROXY" in the choice buttons, below "Configure Proxy Access to the Internet"

    4. refresh web page.

    0 讨论(0)
提交回复
热议问题