AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
139.15k stars 26.41k forks source link

[Bug]: 504 gateway time-out with API #9722

Open EvgenyDanov opened 1 year ago

EvgenyDanov commented 1 year ago

Is there an existing issue for this?

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

DartanyanPatek commented 1 year ago

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

argallo commented 1 year ago

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.

firehawkx commented 1 year ago

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

pnavitha commented 1 year ago

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

firehawkx commented 11 months ago

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 commented 11 months ago

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! :)

gonewilds commented 2 months ago

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