私のハードドライブのルートに仮想環境のDjango pythonサーバーがあります。コマンドラインでenv
を有効にしてpython manage.py 192.168.0.47:80
を実行すると、サーバーの通常の状態(移行通知も何も表示されません)が開始されますが、ブラウザからページをロードすると(instancegaming.net
をローカルで使用します私はDjangoサーバウィンドウに行ってCtrl+C
を実行するとコンソールが更新され、次のようなエラーが表示されます。これは永久にロードしてロードします。このenv
はフレッシュインストールであり、Django以外のサイトパッケージはありません。私は同じサーバ(Windows 10 64ビット)と同じルータの設定で前に正常にサーバを走らせました。Django Python - ターゲットマシンが積極的にそれを拒否したため、接続できませんでした
私は他の投稿(Python Django-Helpdesk Error: No connection could be made because the target machine actively refused it)のようなものをいくつか見てきましたが、どれも問題を解決していないようです。
コンソールウィンドウ:
(env) C:\server\www>python manage.py runserver 192.168.0.47:80
Performing system checks...
System check identified no issues (0 silenced).
December 28, 2016 - 19:07:06
Django version 1.10.4, using settings 'www.settings'
Starting development server at http://192.168.0.47:80/
Quit the server with CTRL-BREAK.
Traceback (most recent call last):
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
response = get_response(request)
File "C:\server\env\lib\site-packages\django\utils\deprecation.py", line 136, in __call__
response = self.get_response(request)
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 41, in inner
response = response_for_exception(request, exc)
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 86, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 124, in handle_uncaught_exception
extra={'status_code': 500, 'request': request},
File "c:\python\Lib\logging\__init__.py", line 1308, in error
self._log(ERROR, msg, args, **kwargs)
File "c:\python\Lib\logging\__init__.py", line 1415, in _log
self.handle(record)
File "c:\python\Lib\logging\__init__.py", line 1425, in handle
self.callHandlers(record)
File "c:\python\Lib\logging\__init__.py", line 1487, in callHandlers
hdlr.handle(record)
File "c:\python\Lib\logging\__init__.py", line 855, in handle
self.emit(record)
File "C:\server\env\lib\site-packages\django\utils\log.py", line 121, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "C:\server\env\lib\site-packages\django\utils\log.py", line 124, in send_mail
mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
File "C:\server\env\lib\site-packages\django\core\mail\__init__.py", line 103, in mail_admins
mail.send(fail_silently=fail_silently)
File "C:\server\env\lib\site-packages\django\core\mail\message.py", line 342, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\server\env\lib\site-packages\django\core\mail\backends\smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "C:\server\env\lib\site-packages\django\core\mail\backends\smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "c:\python\Lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "c:\python\Lib\smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "c:\python\Lib\smtplib.py", line 306, in _get_socket
self.source_address)
File "c:\python\Lib\socket.py", line 711, in create_connection
raise err
File "c:\python\Lib\socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python\Lib\wsgiref\handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "C:\server\env\lib\site-packages\django\core\handlers\wsgi.py", line 170, in __call__
response = self.get_response(request)
File "C:\server\env\lib\site-packages\django\core\handlers\base.py", line 124, in get_response
response = self._middleware_chain(request)
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 41, in inner
response = response_for_exception(request, exc)
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 86, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "C:\server\env\lib\site-packages\django\core\handlers\exception.py", line 124, in handle_uncaught_exception
extra={'status_code': 500, 'request': request},
File "c:\python\Lib\logging\__init__.py", line 1308, in error
self._log(ERROR, msg, args, **kwargs)
File "c:\python\Lib\logging\__init__.py", line 1415, in _log
self.handle(record)
File "c:\python\Lib\logging\__init__.py", line 1425, in handle
self.callHandlers(record)
File "c:\python\Lib\logging\__init__.py", line 1487, in callHandlers
hdlr.handle(record)
File "c:\python\Lib\logging\__init__.py", line 855, in handle
self.emit(record)
File "C:\server\env\lib\site-packages\django\utils\log.py", line 121, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "C:\server\env\lib\site-packages\django\utils\log.py", line 124, in send_mail
mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
File "C:\server\env\lib\site-packages\django\core\mail\__init__.py", line 103, in mail_admins
mail.send(fail_silently=fail_silently)
File "C:\server\env\lib\site-packages\django\core\mail\message.py", line 342, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\server\env\lib\site-packages\django\core\mail\backends\smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "C:\server\env\lib\site-packages\django\core\mail\backends\smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "c:\python\Lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "c:\python\Lib\smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "c:\python\Lib\smtplib.py", line 306, in _get_socket
self.source_address)
File "c:\python\Lib\socket.py", line 711, in create_connection
raise err
File "c:\python\Lib\socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
[28/Dec/2016 19:08:15] "GET/HTTP/1.1" 500 59
マイsettings.py:
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = [
'.instancegaming.net',
]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'www.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'www.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'MST'
USE_I18N = True
USE_L10N = True
USE_TZ = True
ADMINS = (('Jacob J','[email protected]'))
MANAGERS = ADMINS
STATICFILES_DIRS = (
'C:/server/web/static/',
)
STATIC_ROOT = 'C:/server/Apache2/htdocs/cdn/main/'
STATIC_URL = 'http://instancegaming.net:81/cdn/main/'
コンソールエラーはいつでも私が入る押すかCtrl+C
をやって、例えば(コンソールログを更新永遠にループします。 )
私がに行くと、canyouseeme.org、ポート8 0の場合は、と表示され、サービスが表示されます。さらに、私はポート:81
で動作するクリーンなApache 2サーバを持っており、ローカルとリモートの両方で完全にうまく動作します。さらに、私が単にポート80をチェックするためにPythonスクリプトを実行すると、上記と同じ(単純化された)エラーが発生します。
ポートチェッカースクリプト:
import socket
s = socket.socket()
address = '127.0.0.1' # or 192.168.0.47
port = 80 # port number is a number, not string
try:
s.connect((address, port))
# originally, it was
# except Exception, e:
# but this syntax is not supported anymore.
except Exception as e:
print("something's wrong with %s:%d. Exception is %s" % (address, port, e))
finally:
s.close()
次を返し、
[WinError 10061]ターゲットマシンが積極的に、最後
それを拒否したため接続していません私はDjangoが何かを変えることを望むなら、きれいにしてみようとしましたが、それは新鮮な箱のコピーに与えました。まったく同じエラー。
サーバーを別のマシンまたは接続先のマシンで実行していますか? –
あなたのサーバは '192.168.0.47'で動くので、スクリプトでは' 127.0.0.1'を使うことはできません。 – furas
@furasは正しいです。 'python manage.py runserver 0.0.0.0:80'を使って開発サーバを実行してみてください。 – Selcuk