Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errno 10061] No connection could be made because the target machine actively refused it #8

Closed
uyak opened this issue Mar 26, 2013 · 8 comments

Comments

@uyak
Copy link

uyak commented Mar 26, 2013

hi i have this working on local machine when im on accounts/register and try create a new user i get this error
^***************************+

error at /accounts/register/

[Errno 10061] No connection could be made because the target machine actively refused it

Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.5
Exception Type: error
Exception Value:

[Errno 10061] No connection could be made because the target machine actively refused it

Exception Location: C:\Python27\lib\socket.py in create_connection, line 571
Python Executable: C:\Python27\python.exe
Python Version: 2.7.3
Python Path:

['C:\Users\ujake\impromusic\impromusic',
'C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg',
'C:\Python27\lib\site-packages\django_audiotracks-0.2.1-py2.7.egg',
'C:\Python27\lib\site-packages\mutagen-1.20-py2.7.egg',
'C:\Python27\lib\site-packages\django_registration_email-0.5-py2.7.egg',
'C:\Windows\system32\python27.zip',
'C:\Python27\DLLs',
'C:\Python27\lib',
'C:\Python27\lib\plat-win',
'C:\Python27\lib\lib-tk',
'C:\Python27',
'C:\Python27\lib\site-packages',
'C:\Python27\lib\site-packages\PIL',
'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info']

Server time: Tue, 26 Mar 2013 03:55:14 +0100
Traceback Switch to copy-and-paste view

C:\Python27\lib\site-packages\django\core\handlers\base.py in get_response

                            response = callback(request, *callback_args, **callback_kwargs)

    ...
▶ Local vars
C:\Python27\lib\site-packages\registration\views.py in register

                new_user = backend.register(request, **form.cleaned_data)

    ...
▶ Local vars
C:\Python27\lib\site-packages\registration\backends\default\__init__.py in register

                                                                        password, site)

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\db\transaction.py in inner

                    return func(*args, **kwargs)

    ...
▶ Local vars
C:\Users\ujake\impromusic\impromusic\impromusic\apps\registration\models.py in create_inactive_user

                registration_profile.send_activation_email(site)

    ...
▶ Local vars
C:\Users\ujake\impromusic\impromusic\impromusic\apps\registration\models.py in send_activation_email

            self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\contrib\auth\models.py in email_user

            send_mail(subject, message, from_email, [self.email])

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\mail\__init__.py in send_mail

                            connection=connection).send()

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\mail\message.py in send

            return self.get_connection(fail_silently).send_messages([self])

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py in send_messages

                new_conn_created = self.open()

    ...
▶ Local vars
C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py in open

                                               local_hostname=DNS_NAME.get_fqdn())

    ...
▶ Local vars
C:\Python27\lib\smtplib.py in __init__

                (code, msg) = self.connect(host, port)

    ...
▶ Local vars
C:\Python27\lib\smtplib.py in connect

            self.sock = self._get_socket(host, port, self.timeout)

    ...
▶ Local vars
C:\Python27\lib\smtplib.py in _get_socket

            return socket.create_connection((port, host), timeout)

    ...
▶ Local vars
C:\Python27\lib\socket.py in create_connection

            raise err

    ...
▶ Local vars 

Do i have to configure the email server on settings.py for use your app?

@mbrochh
Copy link
Member

mbrochh commented Mar 26, 2013

Yes but the easier way is to put this into your local settings:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

Then all emails will be printed in your console.

If you really want to test your emails, it gets more complicated, an easy way would be to put this into your local settings:

ADMINS = (
    ('Yourname', 'yourname@gmail.com'),
)

MANAGERS = ADMINS


# When you are playing around with the app and you expect that an email should
# have been sent, just run `./manage.py send_mail` and you will get the mail
# to the ADMINS account, no matter who the real recipient was.
MAILER_EMAIL_BACKEND = 'django_libs.test_email_backend.EmailBackend'
TEST_EMAIL_BACKEND_RECIPIENTS = ADMINS

FROM_EMAIL = ADMINS[0][1]
EMAIL_SUBJECT_PREFIX = '[dev yourprojectname] '

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = FROM_EMAIL

# Enter your gmail PW from the ADMINS email entered above.
EMAIL_HOST_PASSWORD = 'yourgmailpw'
EMAIL_PORT = 587

Note that you need to install django-libs for this to work. The test email backend in django-libs makes sure that ALL emails are ALWAYS sent to yourself, no matter who the recipient is. This is super helpful if you downloaded the life database and you are debugging things - without such a test email backend you might accidentally send emails to your users and cause a lot of confusion.

EDIT: The above assumes that you use django-mailer for dispatching your emails (if you don't, you should consider using it, it is awesome)

@uyak
Copy link
Author

uyak commented Mar 26, 2013

ehy ty for your answer it worked and now i can see the activation code on the console, now im having 2 differents error, i have the deprecationgwarning, the md5 module is deprecated, use hashlib instead, i have seen somebody feedbacks it to you, how did he solve it?
The second and maybe is related, when i go to the activation page, something like http://127.0.0.1:8000/accounts/activate/cddfd602398ed8f7801ad46d1634c45d45250c41/ , im having the next error:
************************+

TypeError at /accounts/activate/cddfd602398ed8f7801ad46d1634c45d45250c41/

can't compare offset-naive and offset-aware datetimes

Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/activate/cddfd602398ed8f7801ad46d1634c45d45250c41/
Django Version: 1.5
Exception Type: TypeError
Exception Value:

can't compare offset-naive and offset-aware datetimes

Exception Location: C:\Users\ujake\impromusic\impromusic\impromusic\apps\registration\models.py in activation_key_expired, line 201
Python Executable: C:\Python27\python.exe
Python Version: 2.7.3
Python Path:

['C:\Users\ujake\impromusic\impromusic',
'C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg',
'C:\Python27\lib\site-packages\django_audiotracks-0.2.1-py2.7.egg',
'C:\Python27\lib\site-packages\mutagen-1.20-py2.7.egg',
'C:\Python27\lib\site-packages\django_registration_email-0.5-py2.7.egg',
'C:\Windows\system32\python27.zip',
'C:\Python27\DLLs',
'C:\Python27\lib',
'C:\Python27\lib\plat-win',
'C:\Python27\lib\lib-tk',
'C:\Python27',
'C:\Python27\lib\site-packages',
'C:\Python27\lib\site-packages\PIL',
'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info']

Server time: Tue, 26 Mar 2013 13:03:58 +0100
Traceback Switch to copy-and-paste view

C:\Python27\lib\site-packages\django\core\handlers\base.py in get_response

                            response = callback(request, *callback_args, **callback_kwargs)

    ...
▶ Local vars
C:\Python27\lib\site-packages\registration\views.py in activate

        account = backend.activate(request, **kwargs)

    ...
▶ Local vars
C:\Python27\lib\site-packages\registration\backends\default\__init__.py in activate

            activated = RegistrationProfile.objects.activate_user(activation_key)

    ...
▶ Local vars
C:\Users\ujake\impromusic\impromusic\impromusic\apps\registration\models.py in activate_user

                if not profile.activation_key_expired():

    ...
▶ Local vars
C:\Users\ujake\impromusic\impromusic\impromusic\apps\registration\models.py in activation_key_expired

                   (self.user.date_joined + expiration_date <= datetime.datetime.now())

    ...
▶ Local vars 

Ty so much
EDIT: ty for the tip im installing it now.

@Tyrdall
Copy link
Member

Tyrdall commented Mar 26, 2013

Hi uyak,
seems you have set the PASSWORD_HASHERS setting, right? Please take a look::

https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-PASSWORD_HASHERS

Just remove it or add e.g. 'django.contrib.auth.hashers.PBKDF2PasswordHasher'. MD5 is deprecated in newer Django versions.

Second issue:
In Django 1.5 you need to use timezone. Please take a look::

https://docs.djangoproject.com/en/dev/topics/i18n/timezones/

Maybe it's sufficient to set the USE_TZ setting to True.

https://docs.djangoproject.com/en/dev/ref/settings/#use-tz

Hope this helps.

@mbrochh
Copy link
Member

mbrochh commented Mar 26, 2013

this could also be an issue with django-registration. i get he has USE_TZ
and therefore django saved a timezone aware datetime into activation_date -
but then django-registration tries to compare this against a normal
datetime object. i can only look into this more thoroughly tomorrow
evening...
On 26 Mar 2013 20:24, "Tobias Lorenz" notifications@github.com wrote:

Hi uyak,
seems you have set the PASSWORD_HASHERS setting, right? Please take a
look::

https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-PASSWORD_HASHERS

Just remove it or add e.g.
'django.contrib.auth.hashers.PBKDF2PasswordHasher'. MD5 is deprecated in
newer Django versions.

Second issue:
In Django 1.5 you need to use timezone. Please take a look::

https://docs.djangoproject.com/en/dev/topics/i18n/timezones/

Maybe it's sufficient to set the USE_TZ setting to True.

https://docs.djangoproject.com/en/dev/ref/settings/#use-tz

Hope this helps.


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-15454945
.

@uyak
Copy link
Author

uyak commented Mar 26, 2013

Hy Tyrdalla, ty for your help, i didnt have PASSWORD_HASHERS on settings, i did what you said me and add it on settings.py of my project. Now the error on the shield is


C:/Python27/lib/site-pakages/django/utils/hashcompat.py:9:a DeprecationWarning:Django.utils.hashcompat is deprecated; use hashlib instead


and now if i change the password_hashers i continue having the same new error.

I had USE_TZ = True

Mbrochh i will be waiting ty.

@mbrochh
Copy link
Member

mbrochh commented Mar 26, 2013

that's just a deprecation warning, not an error, you can ignore that. I'll
try to fix it tomorrow...
On Mar 27, 2013 12:15 AM, "uyak" notifications@github.com wrote:

Hy Tyrdalla, ty for your help, i didnt have PASSWORD_HASHERS on settings,
i did what you said me and add it on settings.py of my project. Now the

error on the shield is

C:/Python27/lib/site-pakages/django/utils/hashcompat.py:9:a
DeprecationWarning:Django.utils.hashcompat is deprecated; use hashlib

instead

and now if i change the password_hashers i continue having the same new
error.

I had USE_TZ = True

Mbrochh i will be waiting ty.


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-15468251
.

@mbrochh
Copy link
Member

mbrochh commented Mar 30, 2013

@uyak I have released version 0.5.1 - the deprecation warning should be gone now. Are you still having the timezone error?

@Tyrdall Tyrdall closed this as completed May 29, 2013
@verkko
Copy link

verkko commented Apr 14, 2020

I have tried everything as above. Still am getting error. Can some one please help me.
1
2
3
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants