nanSTA nanSTA - 9 months ago 142
Python Question

Script timed out before returning headers:

I have been trying to deploy my flask app on aws using their elastic beanstalk service but I havnt had any luck. I have tried renaming app to application or import as application. I have tried adding different things to httpf.conf. But, no luck.

Any ideas?

Here is some examples of what i am using/running into.

[Tue Nov 29 04:36:57.477486 2016] [mpm_prefork:notice] [pid 28202] AH00169: caught SIGTERM, shutting down
[Tue Nov 29 04:36:58.593231 2016] [suexec:notice] [pid 28480] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Nov 29 04:36:58.622166 2016] [so:warn] [pid 28480] AH01574: module wsgi_module is already loaded, skipping
[Tue Nov 29 04:36:58.627404 2016] [auth_digest:notice] [pid 28480] AH01757: generating secret for digest authentication ...
[Tue Nov 29 04:36:58.628967 2016] [lbmethod_heartbeat:notice] [pid 28480] AH02282: No slotmem from mod_heartmonitor
[Tue Nov 29 04:36:58.664458 2016] [mpm_prefork:notice] [pid 28480] AH00163: Apache/2.4.23 (Amazon) mod_wsgi/3.5 Python/3.4.3 configured -- resuming normal operations
[Tue Nov 29 04:36:58.667914 2016] [core:notice] [pid 28480] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Tue Nov 29 04:37:02.142727 2016] [:error] [pid 28485] * Running on (Press CTRL+C to quit)
[Tue Nov 29 04:38:05.392413 2016] [core:error] [pid 28509] [client] Script timed out before returning headers:
[Tue Nov 29 04:38:09.386271 2016] [core:error] [pid 28508] [client] Script timed out before returning headers:
[Tue Nov 29 04:38:13.392044 2016] [core:error] [pid 28506] [client] Script timed out before returning headers:
[Tue Nov 29 04:39:04.713037 2016] [core:error] [pid 28532] [client] Script timed out before returning headers:

from northtrack import app as application
from northtrack.models import db

from flask import Flask
from datetime import timedelta
from flask_mail import Message, Mail

from flask_login import LoginManager

from northtrack.models import db, User

import os

mail = Mail()
app = Flask(__name__)

# app.config.from_object(os.environ['APP_SETTINGS'])

app.config["APP_SETTINGS"] = "northtrack.config.DevConfig"


app.permanent_session_lifetime = timedelta(seconds=900)

login_manager = LoginManager()
login_manager.login_view = 'login'
login_manager.login_message_category = "danger"

def load_user(user_id):
return User.query.filter( == int(user_id)).first()

import northtrack.views

Thank you!

Answer Source

This is because somewhere in your code you are starting the builtin Flask developer server. This is evident from the message:

Running on (Press CTRL+C to quit)

Usually this is because is being called, but that is not evident in what you have shown.

Either way, you shouldn't be starting up the Flask development server as mod_wsgi under Apache is acting as the WSGI server.