Python socket programming error

I recently started to learn python and I keep having the same problem in the socket programming section.
I run the same codes in a youtube video that I on my spyder. I followed exact intructions but I cant continue because kernel keep giving me red error.
here are codes

import socket
import threading

PORT = 5050
SERVER = socket.gethostbyname(socket.gethostname())
FORMAT = "utf-8" 

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

def handle_client(conn,addr):
    print(f"NEW CONNECTİON {addr} connected")
    connected = True
    while connected:
        msg.length = conn.recv(HEADER).decode(FORMAT)
        msg.length = int(msg.length)
        msg = conn.recv(msg.length).decode(FORMAT)
        if msg == DISCONNECT_MESSAGE:
            connected = False
    print(f"[{addr}] {msg}")  


def start():
    print(f"[LISTENING] server is listening on {SERVER}")
    conn, addr = server.accept()
    thread= threading.Thread(target=handle_client, args=(conn, addr))
    print(f"[ACTİVE CONNECTİONS] {threading.activeCount()-1}")

the output

(You don’t need to blur out an IP address that starts 192.168 - it’s a private address that only means anything within your local network. For example, I’m currently on a computer with addresses and - but there can be myriad other computers in the world with either or both of those addresses.)

This doesn’t show any errors. What is the problem here? Possibly there’s additional red text that didn’t make it into the screenshot?

It may not be the problem you identified, but there is a (or at least “a”) problem in this code.

Please see: