Error Occurs When Setting DIFY_PORT to a Value Other Than 5001 #8175

Closed
opened 2026-02-21 18:24:20 -05:00 by yindo · 4 comments
Owner

Originally created by @kash203 on GitHub (Feb 12, 2025).

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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I encountered an issue while trying to set a custom port for DIFY_PORT in my .env. When I set the DIFY_PORT to a value other than the default 5001, I receive the following error:

docker-nginx-1       | 2025/02/12 05:19:29 [error] 19#19: *1 connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x, server: _, request: "GET /console/api/setup HTTP/1.1", upstream: "http://x.x.x.x:5001/console/api/setup", host: "x:10080", referrer: "http://x:10080/install"

It appears that the configuration still attempts to connect to the default port 5001 even after changing the environment variable DIFY_PORT.

Steps to Reproduce:

  1. Modify the .env to set DIFY_PORT to a port other than 5001.
  2. Start the Docker container.
  3. Navigate to the URL to trigger the install process.
  4. Observe the error in the logs.

This is a non-blocking report regarding an issue that occurs when the DIFY_PORT environment variable is set to a value other than 5001. While this issue does not currently impede our operations, it may be worth investigating for future improvements.

✔️ Expected Behavior

The application should respect the custom DIFY_PORT value set in the .env and not attempt to connect using the default 5001 port.

Actual Behavior

The application continues to use the default port 5001, leading to a connection failed error.

Originally created by @kash203 on GitHub (Feb 12, 2025). ### 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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I encountered an issue while trying to set a custom port for `DIFY_PORT` in my .env. When I set the `DIFY_PORT` to a value other than the default `5001`, I receive the following error: ``` docker-nginx-1 | 2025/02/12 05:19:29 [error] 19#19: *1 connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x, server: _, request: "GET /console/api/setup HTTP/1.1", upstream: "http://x.x.x.x:5001/console/api/setup", host: "x:10080", referrer: "http://x:10080/install" ``` It appears that the configuration still attempts to connect to the default port `5001` even after changing the environment variable `DIFY_PORT`. **Steps to Reproduce:** 1. Modify the `.env` to set `DIFY_PORT` to a port other than `5001`. 2. Start the Docker container. 3. Navigate to the URL to trigger the install process. 4. Observe the error in the logs. --- This is a non-blocking report regarding an issue that occurs when the DIFY_PORT environment variable is set to a value other than 5001. While this issue does not currently impede our operations, it may be worth investigating for future improvements. ### ✔️ Expected Behavior The application should respect the custom `DIFY_PORT` value set in the .env and not attempt to connect using the default `5001` port. ### ❌ Actual Behavior The application continues to use the default port `5001`, leading to a connection failed error.
yindo added the 🐞 bug label 2026-02-21 18:24:20 -05:00
yindo closed this issue 2026-02-21 18:24:20 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 12, 2025):

Hey there, @kash203! I'm here to help you with any bugs, questions, or contributions you have for DIFY. Let's get this issue sorted out together!

There are a few similar threads related to port configuration issues in Dify:

  1. Help if I want to change the port of nginx, which files should be changed? - This discussion is open and might provide insights into which files need modification when changing ports [1].

  2. it do not work with the right port, when i click run app.(0.10.0beta3) - This closed issue suggests modifying the app_base_url in your configuration to include the port specified in the EXPOSE_NGINX_PORT environment variable and updating your .env file accordingly [2].

To address your issue, ensure that the DIFY_PORT is correctly set in both the docker-compose.yaml and the .env file. Additionally, verify that the Nginx configuration is updated to use the new port. You might need to check if there are any hardcoded references to port 5001 in the Nginx configuration or other parts of the application that need updating.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other | Bug Report

@dosubot[bot] commented on GitHub (Feb 12, 2025): <!-- Greeting --> Hey there, @kash203! I'm here to help you with any bugs, questions, or contributions you have for DIFY. Let's get this issue sorted out together! <!-- Answer --> There are a few similar threads related to port configuration issues in Dify: 1. **[Help if I want to change the port of nginx, which files should be changed?](https://github.com/langgenius/dify/discussions/11884)** - This discussion is open and might provide insights into which files need modification when changing ports <sup>[[1]](https://github.com/langgenius/dify/discussions/11884)</sup>. 2. **[it do not work with the right port, when i click run app.(0.10.0beta3)](https://github.com/langgenius/dify/issues/9411)** - This closed issue suggests modifying the `app_base_url` in your configuration to include the port specified in the `EXPOSE_NGINX_PORT` environment variable and updating your `.env` file accordingly <sup>[[2]](https://github.com/langgenius/dify/issues/9411)</sup>. To address your issue, ensure that the `DIFY_PORT` is correctly set in both the `docker-compose.yaml` and the `.env` file. Additionally, verify that the Nginx configuration is updated to use the new port. You might need to check if there are any hardcoded references to port 5001 in the Nginx configuration or other parts of the application that need updating. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=other) | [Bug Report](https://app.dosu.dev/response-feedback/ffa26ec3-fc57-4c6d-8799-c96bebd6d95f?feedback_type=bug_report)</sup>
Author
Owner

@crazywoola commented on GitHub (Feb 12, 2025):

https://github.com/langgenius/dify/blob/5d91dbd000b94df3a12c579e14a2f29e6e0516cf/api/docker/entrypoint.sh#L29-L39

I don't think you need to change this. 5001 will be used only in docker network.

@crazywoola commented on GitHub (Feb 12, 2025): https://github.com/langgenius/dify/blob/5d91dbd000b94df3a12c579e14a2f29e6e0516cf/api/docker/entrypoint.sh#L29-L39 I don't think you need to change this. `5001` will be used only in docker network.
Author
Owner

@kash203 commented on GitHub (Feb 12, 2025):

@crazywoola Thank you for your quick response.
I agree to your comment.
I want this issue to be used by those who encounter the same situation.

@kash203 commented on GitHub (Feb 12, 2025): @crazywoola Thank you for your quick response. I agree to your comment. I want this issue to be used by those who encounter the same situation.
Author
Owner

@kash203 commented on GitHub (Feb 12, 2025):

(And I apologize for the mistake, but the target for the configuration is not docker compose; it's the .env file.)

@kash203 commented on GitHub (Feb 12, 2025): (And I apologize for the mistake, but the target for the configuration is not docker compose; it's the .env file.)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8175