I can't access localhost/install and get a 502 Bad Gateway after deploying the docker #4366

Closed
opened 2026-02-21 18:06:06 -05:00 by yindo · 9 comments
Owner

Originally created by @gamble369 on GitHub (Jul 1, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.12-fix1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1.This is the first time I ran Dify, so I didn't change anything and .I've pulled the latest code.
2.I tried to search issues like "not reach localhost/install" "localhost" such as #5769 , but I didn't find solution,
3. My OS is Windows Server 2022
4. Here is some information of docker and docker-compose
image

  1. Here is git log
    image

✔️ Expected Behavior

I can access http://localhost/install, I failed, here is srceen-shot and create a new administrator account

Actual Behavior

I wanted to access http://localhost/install, I failed, here is a srceen-shot

1
Originally created by @gamble369 on GitHub (Jul 1, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.12-fix1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1.This is the first time I ran Dify, so I didn't change anything and .I've pulled the latest code. 2.I tried to search issues like "not reach localhost/install" "localhost" such as #5769 , but I didn't find solution, 3. My OS is Windows Server 2022 4. Here is some information of docker and docker-compose ![image](https://github.com/langgenius/dify/assets/64143142/f8606006-9d4c-4b8a-ab4e-fd8dfbece72d) 5. Here is git log ![image](https://github.com/langgenius/dify/assets/64143142/9dc5f65e-f4c1-4ba3-a5fb-55876295530d) ### ✔️ Expected Behavior I can access http://localhost/install, I failed, here is srceen-shot and create a new administrator account ### ❌ Actual Behavior I wanted to access http://localhost/install, I failed, here is a srceen-shot <img width="935" alt="1" src="https://github.com/langgenius/dify/assets/64143142/dee09cec-4f9b-47eb-a685-f4e7c2c2524a">
yindo added the 🐞 bug label 2026-02-21 18:06:06 -05:00
yindo closed this issue 2026-02-21 18:06:06 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 1, 2024):

Hey @gamble369! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together!

To resolve the "502 Bad Gateway" error when trying to access http://localhost/install after deploying the Docker container for Dify version 0.6.12-fix1 on Windows Server 2022, follow these steps:

  1. Ensure Containers are Running:
    Verify that all Docker containers are running:

    docker compose ps
    
  2. Update Nginx Configuration:
    If the containers are running but you still encounter the error, update the Nginx configuration with the correct IP addresses of the docker-web-1 and docker-api-1 containers:

    docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
    

    Note the IP addresses for /docker-web-1 and /docker-api-1.

  3. Modify Nginx Configuration:
    Open the dify/docker/nginx/conf.d directory and replace http://api:5001 with http://<docker-api-1 IP>:5001 and http://web:3000 with http://<docker-web-1 IP>:3000 in the Nginx configuration files.

  4. Restart Nginx:
    Restart the Nginx container or reload the Nginx configuration:

    docker compose restart nginx
    
  5. Check Docker Setup:
    Ensure you have followed the correct steps to start Dify:

    git clone https://github.com/langgenius/dify.git
    cd dify/docker
    cp .env.example .env
    docker compose up -d
    
  6. Access the Installation Page:
    Finally, access http://localhost/install.

For more detailed troubleshooting, refer to the Dify documentation's FAQ section, which provides additional insights and solutions for common issues, including the "502 Bad Gateway" error [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 1, 2024): <!-- Greeting --> Hey @gamble369! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together! <!-- Answer --> To resolve the "502 Bad Gateway" error when trying to access `http://localhost/install` after deploying the Docker container for Dify version 0.6.12-fix1 on Windows Server 2022, follow these steps: 1. **Ensure Containers are Running**: Verify that all Docker containers are running: ```bash docker compose ps ``` 2. **Update Nginx Configuration**: If the containers are running but you still encounter the error, update the Nginx configuration with the correct IP addresses of the `docker-web-1` and `docker-api-1` containers: ```bash docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ``` Note the IP addresses for `/docker-web-1` and `/docker-api-1`. 3. **Modify Nginx Configuration**: Open the `dify/docker/nginx/conf.d` directory and replace `http://api:5001` with `http://<docker-api-1 IP>:5001` and `http://web:3000` with `http://<docker-web-1 IP>:3000` in the Nginx configuration files. 4. **Restart Nginx**: Restart the Nginx container or reload the Nginx configuration: ```bash docker compose restart nginx ``` 5. **Check Docker Setup**: Ensure you have followed the correct steps to start Dify: ```bash git clone https://github.com/langgenius/dify.git cd dify/docker cp .env.example .env docker compose up -d ``` 6. **Access the Installation Page**: Finally, access [http://localhost/install](http://localhost/install). For more detailed troubleshooting, refer to the Dify documentation's FAQ section, which provides additional insights and solutions for common issues, including the "502 Bad Gateway" error <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/learn-more/faq/install-faq.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/docker-compose.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/application-orchestrate/llms-use-faq.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@gamble369 commented on GitHub (Jul 1, 2024):

After I made the changes I got some new situations where these two containers can't be started.
docker-db-1 and docker-nginx-1 fail to start
image
image

the IP addresses for /docker-web-1 and /docker-api-1 is
/docker-web-1: 172.18.0.3
/docker-api-1: 172.18.0.7172.19.0.5
image

@gamble369 commented on GitHub (Jul 1, 2024): After I made the changes I got some new situations where these two containers can't be started. `docker-db-1` and `docker-nginx-1` fail to start ![image](https://github.com/langgenius/dify/assets/64143142/6bb2559c-5271-49f9-8993-7fc480a5e6c0) ![image](https://github.com/langgenius/dify/assets/64143142/225b9a4b-3b24-407a-8919-6c8d237c62d9) the IP addresses for /docker-web-1 and /docker-api-1 is /docker-web-1: 172.18.0.3 /docker-api-1: 172.18.0.7172.19.0.5 ![image](https://github.com/langgenius/dify/assets/64143142/1a1d2580-81b5-4056-960d-f122d6c3aba1)
Author
Owner

@gamble369 commented on GitHub (Jul 1, 2024):

  1. docker-nginx-1 log is
    image

  2. docker-db-1 log is
    image

@gamble369 commented on GitHub (Jul 1, 2024): 1. docker-nginx-1 log is ![image](https://github.com/langgenius/dify/assets/64143142/7c368d2b-5ed8-4148-9f28-e7eb94aae9cf) 2. docker-db-1 log is ![image](https://github.com/langgenius/dify/assets/64143142/56f846a5-2fc2-4446-9909-e5273d3d3208)
Author
Owner

@crazywoola commented on GitHub (Jul 1, 2024):

It seems you haven't copy the environment files. Please make sure you ran cp .env.example .env first before you run docker compose up.

@crazywoola commented on GitHub (Jul 1, 2024): It seems you haven't copy the environment files. Please make sure you ran `cp .env.example .env` first before you run `docker compose up`.
Author
Owner

@crazywoola commented on GitHub (Jul 1, 2024):

https://www.bilibili.com/video/BV1Sx4y1b7BN/?spm_id_from=333.788

@crazywoola commented on GitHub (Jul 1, 2024): https://www.bilibili.com/video/BV1Sx4y1b7BN/?spm_id_from=333.788
Author
Owner

@dalevy0 commented on GitHub (Oct 23, 2024):

@gamble369 sometimes it takes about a minute for the API container to start listening on port 5001, so if you try before it has completely started, all requests to the api container will fail returning a 502. I recommend after running docker compose up, go to docker desktop and check the logs of the api container, then wait until you see the line saying LISTNENING AT HTTP://0.0.0.0:5001
Just then go to localhost and test, this works for me without any further customization :)

image (3)

@dalevy0 commented on GitHub (Oct 23, 2024): @gamble369 sometimes it takes about a minute for the API container to start listening on port 5001, so if you try before it has completely started, all requests to the api container will fail returning a 502. I recommend after running docker compose up, go to docker desktop and check the logs of the api container, then wait until you see the line saying LISTNENING AT HTTP://0.0.0.0:5001 Just then go to localhost and test, this works for me without any further customization :) ![image (3)](https://github.com/user-attachments/assets/62191afe-107c-4f5a-bb17-31efe82dafb2)
Author
Owner

@ViktorMachine commented on GitHub (Jun 16, 2025):

try this, work for me
docker exec -it docker-nginx-1 bash
sbin/nginx -s reload

@ViktorMachine commented on GitHub (Jun 16, 2025): try this, work for me `docker exec -it docker-nginx-1 bash` `sbin/nginx -s reload`
Author
Owner

@truongtn commented on GitHub (Aug 1, 2025):

In my case, install on Debian 6.9.7-1parrot1 (2024-07-18) x86_64 GNU/Linux:

Step 1: Check log: docker logs docker_api_1. (make sure the container is running)

Image

The application crashes due to OpenBLAS failing to create threads. Specifically, it tries to spawn multiple threads for computation, but the operating system denies permission to create them due to process/thread limits. This means:

  • OpenBLAS attempted to create a thread (using pthread_create).
  • The system responded with: Operation not permitted.
  • The process/thread limit (RLIMIT_NPROC) is set to -1, meaning it might be unlimited on host, but inside the container it could be restricted or misinterpreted.
    OpenBLAS cannot initialize multiple threads due to container restrictions on thread creation. This is common in Docker containers that don't explicitly set ulimits, use strict seccomp profiles, or lack OPENBLAS_NUM_THREADS=1 to limit thread usage.

Step 2:
Add these lines on docker-compose.yml, on dify-api section.

Image

security_opt: - seccomp=unconfined ulimits: nproc: 65535 nofile: soft: 65535 hard: 65535
Step 3:
docker-compose down
docker-compose up -d

Step 4:
Access to http://127.0.0.1/install and see the result.

The lession is learn how to check the log and customize the docker-compose.yml.

@truongtn commented on GitHub (Aug 1, 2025): In my case, install on Debian 6.9.7-1parrot1 (2024-07-18) x86_64 GNU/Linux: Step 1: Check log: `docker logs docker_api_1`. (make sure the container is running) <img width="807" height="385" alt="Image" src="https://github.com/user-attachments/assets/0f183589-e209-4772-a16a-6d2946e06e30" /> The application crashes due to OpenBLAS failing to create threads. Specifically, it tries to spawn multiple threads for computation, but the operating system denies permission to create them due to process/thread limits. This means: - OpenBLAS attempted to create a thread (using pthread_create). - The system responded with: Operation not permitted. - The process/thread limit (RLIMIT_NPROC) is set to -1, meaning it might be unlimited on host, but inside the container it could be restricted or misinterpreted. OpenBLAS cannot initialize multiple threads due to container restrictions on thread creation. This is common in Docker containers that don't explicitly set ulimits, use strict seccomp profiles, or lack OPENBLAS_NUM_THREADS=1 to limit thread usage. Step 2: Add these lines on docker-compose.yml, on dify-api section. <img width="272" height="194" alt="Image" src="https://github.com/user-attachments/assets/29a69903-2502-4ac0-a408-493ee52d5941" /> ` security_opt: - seccomp=unconfined ulimits: nproc: 65535 nofile: soft: 65535 hard: 65535 ` Step 3: `docker-compose down` `docker-compose up -d` Step 4: Access to http://127.0.0.1/install and see the result. The lession is learn how to check the log and customize the docker-compose.yml.
Author
Owner

@maoguy commented on GitHub (Jan 7, 2026):

try this, work for me docker exec -it docker-nginx-1 bash sbin/nginx -s reload

worko( ̄▽ ̄)d

@maoguy commented on GitHub (Jan 7, 2026): > try this, work for me `docker exec -it docker-nginx-1 bash` `sbin/nginx -s reload` worko( ̄▽ ̄)d
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4366