pallets / flask

The Python micro framework for building web applications.
https://flask.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
67.85k stars 16.2k forks source link

url_for: 500 Internal Server Error #1587

Closed tfarina closed 9 years ago

tfarina commented 9 years ago

In Flaskr example, I'm getting the following for url_for('add_entry')

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

This is running behind uwsgi with emperor mode. Logs are absent and do not show the real problem and I'm unable to diagnose.

ThiefMaster commented 9 years ago

Run the app in debug mode (app.debug = True) to see the exception/traceback.

Also, during local development/testing the builtin dev server is pretty useful. No need for a full-blown webserver. It just makes things more complex.

tfarina commented 9 years ago

That is one of the problems. When running the app with python directly it does work and shows '/add' correctly. When I move to the nginx + uwsgi it shows this 500 error.

davidism commented 9 years ago

Configure Python's logging to enable Flask's traceback output in production. The following example configures it to print to stderr, which should get captured by uWSGI. Please post the full traceback.

import logging
handler = logging.StreamHandler()
handler.setLevel(logging.ERROR)
app.logger.addHandler(handler)
tfarina commented 9 years ago

I didn't get anything on terminal with that.

tfarina commented 9 years ago

When I change it to {{ url_for('index') }} it returns '/microblog/'. For anything else it returns 500 error.

tfarina commented 9 years ago

But I need {{ url_for('add_entry') }} to return '/microblog/add'

davidism commented 9 years ago

There's not enough information here to continue. Try configuring logging to log to a file instead, if uWSGI isn't picking up stderr.

tfarina commented 9 years ago

OK @davidism, thanks for your support!

tfarina commented 9 years ago

For future reference I was able to get some backtrace following http://librelist.com/browser/flask/2012/1/27/catching-exceptions-from-flask/#e3f303db052ce2bdae0801269b51d55d

I had to add --catch-exceptions to uwsgi command line and app.config['PROPAGATE_EXCEPTIONS'] = True to the application.

chaitanya9899 commented 4 years ago

i got error in flask applications

Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

chaitanya9899 commented 4 years ago

how to rectify the error?

ThiefMaster commented 4 years ago

@chaitanya425 Both your comments are completely useless. You posted a super generic error message and nothing else. What do you expect us or anyone else to do there?

chaitanya9899 commented 4 years ago

@ThiefMaster i need solution

ThiefMaster commented 4 years ago

Seriously, what do you expect? You didn't even post any code. Anyway, this is the wrong place. Go to Stack Overflow or our Discord/IRC channel, and share your code. Debug mode also help in seeing what's actually failing.

chaitanya9899 commented 4 years ago

@ThiefMaster cool bro i need help in error (500 Internal Server Error) do you have solution please tell me otherwise. i know stack overflow ok .