Heroku / gunicorn / flask app says "Connection to use"

I have a Flask application that works fine on the local computer, but when I click on Heroku, I get an error:

* Running on http://127.0.0.1:5000/ [INFO] Starting gunicorn 18.0 [ERROR] Connection in use: ('0.0.0.0', 8163) 

I tried the solution in this question , where the militants and werkzeug fought each other, but adding the __name__ == "__main__" block to my main application file ( run.py ) did not solve my mistake.

This SO post suggested making sure my processes were cleaned up. I did this, but it still did not work, so I actually uninstalled my heroku application and canceled it, and it still gives the same error.

My run.py file looks like this:

 #!pl_env/bin/python from app import app if __name__ == "__main__": app.run(debug=True, port=33507) # [33507 is the Flask port on Heroku] 

And my Procfile : web: gunicorn run: application

The __init__.py file in the application:

 from flask import Flask import os from flask.ext.login import LoginManager app = Flask(__name__) app.config.from_object('config') lm = LoginManager() lm.init_app(app) lm.login_view = 'login' from app import views 

There is fleshy application logic in the views, but I don’t think there is anything there that will be random with the gun. Here import.py imports only if:

 from flask import Flask, render_template, flash, redirect from flask.ext.login import login_required, login_user from app import app, lm from forms import LoginForm 

I definitely do not understand where to look now to find out this connection error. Any thoughts on why it seems like I'm already using 0.0.0.0 ?

thanks

Monica

EDIT: I ran the application locally using foreman start and it worked cleanly at 0.0.0.0:5000 , so I think I have a Heroku problem

EDIT2: I intentionally broke the flow of the view - made an internal infinite link - and pushed it to see what happens. I got the expected error logs, unzipped it and pressed the rollback, and now it works. I have absolutely no idea why this should work, except that maybe it breaks it in the expected order in order to rekindle my connections with weapons. If anyone has any explanation for this mystery, I will love them.

+6
source share
1 answer
 app.run(host='0.0.0.0') 

can do the trick as described here

0
source

Source: https://habr.com/ru/post/959432/


All Articles