[Python] Django UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 5:...

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have not seen such a problem before. I rummaged through Google and did not find an answer. Although other people had similar issues, but their solutions did not suit mine. (Username in English path too)

    Problem: in first Django project manage.py runserver has error:

    Performing system checks...

    System check identified no issues (0 silenced).

    You have 18 unapplied migration(s). Your project may not work properly until you
    apply the migrations for app(s): admin, auth, contenttypes, sessions.
    Run 'python manage.py migrate' to apply them.
    August 04, 2022 - 01:06:46
    Django version 4.1, using settings 'base.settings'
    Starting development server at http://127.0.0.1:8000/
    Quit the server with CTRL-BREAK.
    Exception in thread django-main-thread:
    Traceback (most recent call last):
    File "C:\pthn\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
    File "C:\pthn\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
    File "C:\pthn\lib\site-packages\django\utils\autoreload.py", line 64, in wrapp
    er
    fn(*args, **kwargs)
    File "C:\pthn\lib\site-packages\django\core\management\commands\runserver.py",
    line 158, in inner_run
    run(
    File "C:\pthn\lib\site-packages\django\core\servers\basehttp.py", line 236, in
    run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
    File "C:\pthn\lib\site-packages\django\core\servers\basehttp.py", line 76, in
    __init__
    super().__init__(*args, **kwargs)
    File "C:\pthn\lib\socketserver.py", line 452, in __init__
    self.server_bind()
    File "C:\pthn\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
    File "C:\pthn\lib\http\server.py", line 140, in server_bind
    self.server_name = socket.getfqdn(host)
    File "C:\pthn\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 5: invalid
    continuation byte


    host folder(C:\Windows\System32\drivers\etc) -

    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    # localhost name resolution is handled within DNS itself.
    # 127.0.0.1 localhost
    # ::1 localhost

    Continue reading...

Compartilhe esta Página