Opened 7 years ago

Closed 7 years ago

#7040 closed (invalid)

Friendlier error messages when database connection fails on runserver startup

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


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> 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\", line 47, in inner_run
  File "C:\Program Files\Django\django\core\management\", line 112, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\Program Files\Django\django\core\management\", line 68, in get_validation_errors
    db_version = connection.get_server_version()
  File "C:\Program Files\Django\django\db\backends\mysql\", line 195, in get_server_version
  File "C:\Program Files\Django\django\db\backends\", line 33, in cursor
    cursor = self._cursor(settings)
  File "C:\Program Files\Django\django\db\backends\mysql\", line 182, in_cursor
    self.connection = Database.connect(**kwargs)
  File "C:\Program Files\Python\lib\site-packages\MySQLdb\", line 74, in Connect
    return Connection(*args, **kwargs)
  File "C:\Program Files\Python\lib\site-packages\MySQLdb\", 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 Changed 7 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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