# Encoding with 'idna' codec failed (UnicodeError: label empty or too long)

**URL:** <https://forum.djangoproject.com/t/encoding-with-idna-codec-failed-unicodeerror-label-empty-or-too-long/20568>\
**Category:** Forms & APIs\
**Created:** [April 27, 2023, 12:09pm UTC](https://forum.djangoproject.com/t/encoding-with-idna-codec-failed-unicodeerror-label-empty-or-too-long/20568 "2023-04-27T12:09:13Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 27, 2023, 4:26pm UTC](https://forum.djangoproject.com/t/encoding-with-idna-codec-failed-unicodeerror-label-empty-or-too-long/20568/12 "2023-04-27T16:26:29Z")

</div>

Open up a command line window, activate the virtual environment, and run the `python` command to get into the python shell.

In the shell, run the following commands and report back what the results are:

(No output is expected from this first command)  
`import socket`

`socket.gethostname()`

`socket.getfqdn()`

`socket.getfqdn('127.0.0.1')`

---

_[View the full topic](https://forum.djangoproject.com/t/encoding-with-idna-codec-failed-unicodeerror-label-empty-or-too-long/20568)._
