stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: 504 gateway time-out with API

Open EvgenyDanov opened this issue 2 years ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

When using the API, if the request lasts more than a minute, I get the error 504 gateway time-out

Steps to reproduce the problem

  1. connect the API
  2. make a request

What should have happened?

there should be no mistake

Commit where the problem happens

https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/a9eab236d7e8afa4d6205127904a385b2c43bb24

What platforms do you use to access the UI ?

Other/Cloud

What browsers do you use to access the UI ?

No response

Command Line Arguments

!python /content/gdrive/$mainpth/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --opt-sdp-attention $auth --disable-console-progressbars

List of extensions

image

Console logs

[Errno Expecting value] <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>

Additional information

No response

EvgenyDanov avatar Apr 18 '23 20:04 EvgenyDanov

exactly the same problem, not fixed with --gradio-queue

DartanyanPatek avatar Apr 19 '23 00:04 DartanyanPatek

I created a fix for this on my fork, the problem is hitting the txt2img endpoint holds its connection open until the images generate however this should really be a fire and forget request since we have a check progress endpoint anyways. So with my fix when you request txt2img the checkprogress response will eventually return the processed images no matter how long it takes since this endpoint is being hit periodically instead of being kept alive the whole time. I'll try to add a PR today for it.

argallo avatar May 21 '23 04:05 argallo

Any chance for this latest fix to be merged with the main repo?

I am using runpods with the Fast-Stable-Diffusion preset and getting this all the time when doing bigger x,y,z grids in the webuiapi

firehawkx avatar Aug 28 '23 21:08 firehawkx

Facing the same issue with automatic1111 API txt2img. Any fix??

pnavitha avatar Aug 31 '23 11:08 pnavitha

I created a patch from "argallo" fork that applied on the latest 1.6 version of auto1111, however sadly this didnt solve the issue and the time-out problem still occurs... Patch504.patch

firehawkx avatar Sep 25 '23 13:09 firehawkx

The team I work with actually figured out a workaround / fix for the problem!! (unsure what the equivalent would be on windows however) But in this file : /etc/nginx/nginx.conf you simply add these 2 lines :

    fastcgi_read_timeout 300;
     proxy_read_timeout 300;

inside the starting http bracket like so :

http {
     fastcgi_read_timeout 300;
     proxy_read_timeout 300;
}

and it works!! no more time-out!!

Another solution to automate the process is to run this in a terminal window :

sed -i '/http {/a \    fastcgi_read_timeout 999999;\n\    proxy_read_timeout 999999;' /etc/nginx/nginx.conf
service nginx restart

Hope it helps someone one day! :)

firehawkx avatar Sep 26 '23 16:09 firehawkx

i got this problem couple weeks ago, and what i do is using nginx as api endpoints instead of localhost/gradio. just add --nging [auth token] when launch the ui/api

gonewilds avatar Jun 23 '24 11:06 gonewilds