Getting an error when deploying Flask App

Question:
I can run the app in development but getting an error when I try to deploy. No errors message in the log but the deployment status asked me to post it here.
error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information. For additional support, please post on https://ask.replit.com/c/help/13 and a staff member will take a look. - 2023-10-07T19:56:56.794Z
Repl link/Link to where the bug appears:
https://replit.com/@KiranN4/GitaGuru
Screenshots, links, or other helpful context:

code snippet

Log Error: hostingpid1: an open port was not detected


I am having same issue and its been happening for days, deployment issues should please be resolved

Also, tried adding the port 5000 or 8080 directly to the .replit file. Doesn’t work for either.

All,

Could you answer the following:

  1. Does their Repl work in the workspace (as stated in the interface)
  2. Is their app using the same run command that it is in the workspace

You can also take a look at our Deployments guide here: https://docs.replit.com/hosting/deployments/faq for any additional help.

1 Like
  1. Yes, it works in development workspace.
  2. The command in the .replit file is run = "python3 main.py", so I believe yes.
    Console shows the following:
* Serving Flask app 'main'
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://172.31.196.19:5000

This has been posted for more than a week. No help?

Kiran,

You’ll need to expose to port 80, which is the only open port. Once you do that, it should be OK. Please let us know if you have any further questions.

How do you expose port 80?

Set line 34 to

port = 80

Looks like it’s working now! To address the earlier comments, it is not necessary to listen only on port 80 – any port will do, as long as the listening address is 0.0.0.0.

1 Like

the issue has been resolved

Hey @GRANDS-ROISROIS. It’s great to hear that you’ve fixed your problem, but please provide an explanation to how you did, so that other people who have the same problem know the solution.

2 Likes