Opened 17 years ago

Closed 17 years ago

#7040 closed (invalid)

Friendlier error messages when database connection fails on runserver startup

Reported by: Emil Stenström Owned by: nobody
Component: django-admin.py runserver Version: dev
Severity: Keywords:
Cc: em@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

My most common error when starting the development server (runserver) is that I have forgot to start my database. When I do this I get a nasty stacktrace in the face. I suggest that you specifically look for database connection error and present the user with a friendlier error message.

Current error:

C:\mysite>manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x00CC52B0>
Traceback (most recent call last):
  File "C:\Program Files\Django\django\core\management\commands\runserver.py", line 47, in inner_run
    self.validate(display_num_errors=True)
  File "C:\Program Files\Django\django\core\management\base.py", line 112, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\Program Files\Django\django\core\management\validation.py", line 68, in get_validation_errors
    db_version = connection.get_server_version()
  File "C:\Program Files\Django\django\db\backends\mysql\base.py", line 195, in get_server_version
    self.cursor()
  File "C:\Program Files\Django\django\db\backends\__init__.py", line 33, in cursor
    cursor = self._cursor(settings)
  File "C:\Program Files\Django\django\db\backends\mysql\base.py", line 182, in_cursor
    self.connection = Database.connect(**kwargs)
  File "C:\Program Files\Python\lib\site-packages\MySQLdb\__init__.py", line 74, in Connect
    return Connection(*args, **kwargs)
  File "C:\Program Files\Python\lib\site-packages\MySQLdb\connections.py", line 170, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

Change History (1)

comment:1 by Alex Gaynor, 17 years ago

Resolution: invalid
Status: newclosed

I'm going to mark this as invalid, the error message clearly says that it could not connect to the database, trying to offer a simpler error message will backfire when a complicated case occurs and the user is being given simplified messages that are of no help.

Note: See TracTickets for help on using tickets.
Back to Top