Es wurde versucht, einen Socket-Vorgang in einem nicht erreichbaren Netzwerk in Python httplib auszuführen

Ich versuche, mit httplib einen REST-Client aus Django zu erstellen. Aber es lehnt die Verbindung ab. Ich habe Folgendes versucht

import hashlib
import hmac
from django.shortcuts import render_to_response
from django.template import RequestContext

def loginAction(request):
    username=request.POST['email']
    password=request.POST['password']
    import httplib, urllib
    params = urllib.urlencode({'username': username})
    #hash username here to authenticate
    digest=hmac.new("qnscAdgRlkIhAUPY44oiexBKtQbGY0orf7OV1I50", str(request.POST['password']),hashlib.sha1).hexdigest()
    auth=username+":"+digest
    headers = {"Content-type": "application/json","Accept": "text/plain","Authorization":auth}
    conn = httplib.HTTPConnection("10.0.2.2",8000)
    conn.request("POST", "/api/ecp/profile/", params, headers)

gibts aber folgenden fehler

[Errno 10051] A socket operation was attempted to an unreachable network

Was könnte das Problem sein?

Danke

Antworten auf die Frage(1)

Ihre Antwort auf die Frage