1

This is very possibly a duplicate, since I saw a certain amount of similar questions but I can't seem to find a solution.

My problem is as stated in the description. I am working on a Django project on python 3.8.5. My professor wanted me to program a website and use PostgreSQL as db. I did use it but I always got the following error when I used python manage.py runserver.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 1: invalid continuation byte

I uninstalled PostgreSQL and tryed to start a older project of mine that uses sqlite3, but it did not work and threw the same error. Following the stack trace.

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Startklar\PycharmProject\Modul133_Movie\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Startklar\PycharmProject\Modul133_Movie\venv\lib\site-packages\django\core\management\commands\runserver.py", line 139, in inner_run
    run(self.addr, int(self.port), handler,
  File "C:\Users\Startklar\PycharmProject\Modul133_Movie\venv\lib\site-packages\django\core\servers\basehttp.py", line 206, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\Users\Startklar\PycharmProject\Modul133_Movie\venv\lib\site-packages\django\core\servers\basehttp.py", line 67, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\http\server.py", line 140, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Users\Startklar\AppData\Local\Programs\Python\Python38\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 1: invalid continuation byte

I am running this entire thing locally on a Windows 10.

I have no clue whatsoever on how to solve this issue. I am really new to django and even my professor can't seem to help me. I have been looking through a variety of questions here in stack overflow and tried a numbers of things out but I can't seem to find a solution at all.

Every bit of help or advice is welcomed.

1 Answer 1

2

Your database table or columns may be using a different encoding. Try running the following query in SQL:

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8;

This will change the character set of your table to UTF-8.

Also found an issue similar to yours:

Unicodedecodeerror with runserver

It may have to do with non-ASCII characters in the hostname or computer name.

Sign up to request clarification or add additional context in comments.

1 Comment

Never mind. I am an idiot. And a big one to. Thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.