Codax
Codax

Reputation: 41

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 2: invalid start byte

hello i'm trying a "python manage.py runserver" command in the cmd
but it returned me this eroor:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 2: invalid start byte"

on the position

"socket.py", line 791, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)

Here ist the original code in the editor:

def getfqdn(name=''):
     name = name.strip()
    if not name or name == '0.0.0.0':
        name = gethostname()
    try:
        hostname, aliases, ipaddrs = gethostbyaddr(name)
    except error:
        pass
    else:
        aliases.insert(0, hostname)
        for name in aliases:
            if '.' in name:
                break
        else:
            name = hostname
    return name

I have no idea how i can bypass this error since i am not sure if i understand the code.
(first time asking question, thanks for your help!)

Upvotes: 3

Views: 1485

Answers (1)

BiOS
BiOS

Reputation: 2304

It looks like name contains invalid characters the time it is given as argument to gethostbyaddr() in the socket module.

This is likely because your hostname actually does contains special characers. You may check for this by opening the Terminal or the Command Prompt and type in hostname

If you get something like this as a result:

računalo-codax 

(The above is Croatian for "Codax-computer")

Then you need to change your computer name to make sure it does not contain any special characters like that č. Only plain letters a-zA-Z and numbers 0-9, or a dash -.

Upvotes: 1

Related Questions