I have Django App and I am trying to get data from our server. The code is as below:
def login(request):
#global userlist, login_data
if request.method == "POST":
# get email or mobile_number and password from login.html screen
email_id = request.POST.get("your_name")
password = request.POST.get("your_pass")
try:
login_data = requests.get('http://<our URL>/api/usersapi/?mobile_number=' + email_id + '&password=' + password, timeout=0.05).json() # get user api json data
if len(login_data) == 1: # check dictionary of login_data is empty or not
for x in login_data:
user_type = x['user_type']
user_id = x['user_id']
request.session['login_data'] = user_id
request.session["admin_status"] = True
return render(request, 'gui/dashboard.html', {'user_type': user_type, 'login_data': login_data})
else: # if correct details then return to dashboard page
return render(request, 'gui/login.html', {'msg': 'Wrong Username and Password'})
except requests.exceptions.ConnectionError as e:
print(e)
r = "No response"
return render(request, 'gui/login.html', {'msg': e})
return render(request, 'gui/login.html')
It throws an error while establishing the connection.
HTTPConnectionPool Max retries exceeded with (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3b389becc0>: Failed to establish a new connection: [Errno 111] Connection refused',
I have already seen and applied many solutions related to the same error. But, I am not able to figure out the problem. Our system ulimit-> 65536
I have configured settings using WSGI. and /etc/hosts has our url entry
Any help or guidence is appreciated.
Regards, PD