Sudden URLError
I have a crm app that has been working fine until today. There are two registration options, one where I can manually add a user, the second - a user sets up their own account. Both options were working well until today (the first option is still working) but When users complete the sign up page they get the following error (code is at the very bottom):
URLError at /register/150
<urlopen error [Errno -3] Temporary failure in name resolution>
Request Method: POST
Request URL: http://INSERT URL/register/150
Django Version: 3.2
Exception Type: URLError
Exception Value:
<urlopen error [Errno -3] Temporary failure in name resolution>
Exception Location: /usr/lib/python3.8/urllib/request.py, line 1357, in do_open
Python Executable: /home/django/regenv/bin/python
Python Version: 3.8.10
Python Path:
['/home/django/registrations',
'/home/django/regenv/bin',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/django/regenv/lib/python3.8/site-packages']
Server time: Wed, 30 Apr 2025 21:05:48 +0000
Traceback Switch to copy-and-paste view
/usr/lib/python3.8/urllib/request.py, line 1354, in do_open
h.request(req.get_method(), req.selector, req.data, headers, …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 1256, in request
self._send_request(method, url, body, headers, encode_chunked) …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 1302, in _send_request
self.endheaders(body, encode_chunked=encode_chunked) …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 1251, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked) …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 1011, in _send_output
self.send(msg) …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 951, in send
self.connect() …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 1418, in connect
super().connect() …
▶ Local vars
/usr/lib/python3.8/http/client.py, line 922, in connect
self.sock = self._create_connection( …
▶ Local vars
/usr/lib/python3.8/socket.py, line 787, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM): …
▶ Local vars
/usr/lib/python3.8/socket.py, line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags): …
▶ Local vars
During handling of the above exception ([Errno -3] Temporary failure in name resolution), another exception occurred:
/home/django/regenv/lib/python3.8/site-packages/django/core/handlers/exception.py, line 47, in inner
response = get_response(request) …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/core/handlers/base.py, line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) …
▶ Local vars
/home/django/registrations/accounts/views.py, line 794, in registerPage
if create_form.is_valid() and pay_form.is_valid() and order_form.is_valid(): …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/forms/forms.py, line 175, in is_valid
return self.is_bound and not self.errors …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/forms/forms.py, line 170, in errors
self.full_clean() …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/forms/forms.py, line 372, in full_clean
self._clean_fields() …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/forms/forms.py, line 390, in _clean_fields
value = field.clean(value) …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/django/forms/fields.py, line 150, in clean
self.validate(value) …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/captcha/fields.py, line 69, in validate
check_captcha = client.submit( …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/captcha/client.py, line 63, in submit
response = recaptcha_request(params) …
▶ Local vars
/home/django/regenv/lib/python3.8/site-packages/captcha/client.py, line 38, in recaptcha_request
return opener.open( …
▶ Local vars
/usr/lib/python3.8/urllib/request.py, line 525, in open
response = self._open(req, data) …
▶ Local vars
/usr/lib/python3.8/urllib/request.py, line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol + …
▶ Local vars
/usr/lib/python3.8/urllib/request.py, line 502, in _call_chain
result = func(*args) …
▶ Local vars
/usr/lib/python3.8/urllib/request.py, line 1397, in https_open
return self.do_open(http.client.HTTPSConnection, req, …
▶ Local vars
/usr/lib/python3.8/urllib/request.py, line 1357, in do_open
raise URLError(err) …
▶ Local vars
def registerPage(request, amount):
page_heading = 'Registration Page'
amount_paid = amount
create_form = CreateUserForm()
pay_form = Se lfBuildPaymentForm()
order_form = BuildOrderForm()
training = TrainingInstance.objects.all()
if request.method == 'POST':
create_form = CreateUserForm(request.POST)
pay_form = SelfBuildPaymentForm(request.POST)
order_form = BuildOrderForm(request.POST)
if create_form.is_valid() and pay_form.is_valid() and order_form.is_valid():
user = create_form.save()
username=create_form.cleaned_data.get('username')
group = Group.objects.get(name='customer')
user.groups.add(group)
training = order_form.cleaned_data.get('training_registered')
Customer.objects.create(
user=user,
username=user.username,
first_name = create_form.cleaned_data.get('first_name'),
last_name = create_form.cleaned_data.get('last_name'),
email = create_form.cleaned_data.get('email'),
phone = create_form.cleaned_data.get('tel'),
temp_pass = create_form.cleaned_data.get('password1'),
)
MedicalForm.objects.create(customer=user.customer)
ReleaseForm.objects.create(customer=user.customer)
MonitoringForm.objects.create(customer=user.customer)
ParticipantPayment.objects.create(
customer=user.customer,
payment_1_amount = amount_paid,
payment_1_date = datetime.date.today()
)
FoodAllergies.objects.create(
customer=user.customer,
training_registered = order_form.cleaned_data.get('training_registered'),
)
Order.objects.create(
customer=user.customer,
training_registered = order_form.cleaned_data.get('training_registered'),
releaseform = ReleaseForm.objects.get(customer=user.customer),
registration_date = pay_form.cleaned_data.get('payment_1_date'),
medicalform = MedicalForm.objects.get(customer=user.customer),
monitoringform = MonitoringForm.objects.get(customer=user.customer),
foodform = FoodAllergies.objects.get(customer=user.customer, training_registered = order_form.cleaned_data.get('training_registered')),
par_payment = ParticipantPayment.objects.get(customer=user.customer),
)
order = Order.objects.get(customer__username= username, training_registered = training)
payment = ParticipantPayment.objects.get(
customer=user.customer)
payment.fee = order.training_registered.reg_fee
payment.currency = order.training_registered.currency
payment.save()
messages.success(request, 'An Account was created for ' + username +' was successfully created. log in to proceed.')
username=user.username
firstname = create_form.cleaned_data.get('first_name')
lastname = create_form.cleaned_data.get('last_name')
email = create_form.cleaned_data.get('email')
nwta = order.training_registered.name
subject = 'NAME: ' + firstname + ' ' + lastname + ' created a user account.'
message = 'A user account has been created by:\n'
message += username + ' - ' + firstname + ' ' + lastname + ' for the ' + nwta + ' NWTA.'
send_mail(
subject,
message,
'EMAIL ADDRESS',
['EMAIL ADDRESS2', 'EMAIL ADDRESS3'],
fail_silently=False,
)
subject2 = 'User account registered'
message2 += 'A user account has been created by:\n'
message2 += firstname + ' ' + lastname + ' using ' + email +' for the ' + nwta + ' NWTA.\n'
message2 += 'To log back in to your forms, go to URL\n'
message2 += 'If you get an error message saying that you are not authorised to view the page then go to:\n'
message2 += 'URL and then try again. If you have any problems then email enrolment@mankindprojectuki.org'
send_mail(
subject2,
message2,
'email address ',
['email address 2', 'email address 3'],
fail_silently=False,
)
return redirect('logout')
context = {'create_form':create_form,'pay_form':pay_form, 'order_form':order_form,'training':training,'page_heading': page_heading}
return render(request, 'accounts/register.html', context)