I am get a little crazy with Django development server
Since yesterday, i got the following message:
0 errors found January 17, 2014 - 17:49:31
Django version 1.6.1, using settings 'applibs.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Error: You don't have permission to access that port.
And this, independently from the port i use...i tried with 8081, 8082 and so on.
I must have changed something but i can't figure out what exactly
Any help would be welcomed
thanks
EDIT: Reason Found!
I finally understand the reason for such problem and it has nothing to do with the ports as it initially seems to be.
Indeed, i am initiating a logger in Wsgi.py as shown below
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s \t %(name)s \t %(levelname)s \t %(message)s', datefmt='%Y-%m-%d %H:%M:%S',filename=os.path.join(settings.BASE_DIR,'applibs.log'))
All traces are logged in a file called applibs.log
If the file does not exist, it is automatically created.
If i run the development server, the file will be created with the current user as owner and group.
If i run a production server (ie. apache), the file will be created with the apache user (www-data) as owner and group.
In any case, the file is created with write access only to the user.
So what happened?
I ran the application on a production server. The file was created with user www-data.
Then when i tried to run the application in development server, the application was trying to access the same file (which has already been created) with the current user and so the access is refused.
Et voila :)
Related
I'm facing Authentication unsuccessful error when I try to send mail from Apache Superset.
I checked the document's SMTP integration chapter:https://apache-superset.readthedocs.io/en/latest/installation.html
I changed SMTP_PASSWORD parameter and I entered password manually in my config.py file like SMTP_PASSWORD = "'xxx!!'" (I added '' because my password includes special character like '!'. Also, I tried SMTP_PASSWORD="xx!!" but also I'm getting error.
smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful')
I can login with my SMTP user via browser (Exchange). Could you please help me to solve this issue?
Apache Superset version: 1.3.2
Python version:3.8
OS version: RHEL 8
Thanks
You might be able to poke at this by checking your SMTP connection from inside your Superset instance.
From where your Superset instance should be sending the emails, start a Python script and try:
import smtplib
server = smtplib.SMTP('smtpservername.yourdomain', yourportnumber)
If that command fails or hangs indefinitely, you know there's a connection problem. You might try connecting to the GMail SMTP server or another known-to-work set of credentials and seeing if that works to narrow it down.
For instance, if running Superset with docker-compose you would enter the worker container with docker exec -it superset_worker /bin/bash, run python, and try this there.
My scheduled reports were failing and doing this helped me isolate a cause: my Superset instance could not connect to the target unauthenticated SMTP server.
I cannot access localhost / 0.0.0.0:8000 from any other device.
The current django project is built off of an older project I was playing around with last year where this worked. Unfortunately i've lost the previous project so I cannot compare their settings.py files, although there should be hardly any difference between them.
.
The setup
Dropbox - holds project and sqlite database file
Laptop - running
server, had no changes over last year
Desktop - /
iPhone - /
.
Where the problem is
The fault must be on my laptop where the server is running because I cannot access the server on either my desktop nor my iPhone, the latter worked last year with the previous project, I did not have my desktop at the time.
.
The project's allowed hosts list
I've added several as i've been trying out different solutions recommended by others.
ALLOWED_HOSTS = [
'*',
'0.0.0.0.',
'0.0.0.0:8000',
'localhost'
'localhost:8000'
'{laptop's IP address}',
'{desktop's IPv4 address}',
'{desktop's Default gateway}',
]
.
When I try to access the localhost on desktop or iPhone
Nothing appears in the laptop's terminal, the quit server help line remains the last line. I remember last year, it would update with notifcations that something remotely was accessing the server.
On the desktop, Firefox tells me it's 'Unable to connect', Edge tells me 'localhost refused to connect' with a 'ERR_CONNECTION_REFUSED'.
On the iPhone, 'could not connect to the server'.
.
what I've tried in the other devices' URL address bar
0.0.0.0:8000
localhost:8000
localhost:8000/admin
https://{laptop IP address}
.
.
Any help would be appreciated.
To host on a local network, first ensure that your IP address is added to the ALLOWED_HOSTS of settings.py.
ALLOWED_HOSTS = ['192.168.1.X']
Note: Your IP address can be locate via running ipconfig in the command prompt
Ensure you also execute runserver on ip address 0.0.0.0:8000. For example:
python manage.py runserver 0.0.0.0:8000
When connecting with other devices put the IP address and the port number of the host in the URL within the browser. Like so:
192.168.1.X:8000/<app_name>/other_pages
So I have set up my Django server through an SSH connection to my remote server. It shows me that the server is actually running:
August 10, 2020 - 04:09:47
Django version 3.1, using settings 'risk_areas.settings'
Starting development server at http://xx.xxx.xxx.xxx:8000/
Quit the server with CONTROL-C
However, if I try to go to the URL above (with my IP address in it) it gives me a connection time out error. What might be the reason for this?
I have a small project with basic crud operations done in django, in my local it works fine, now I have uploaded it into a live domain, and run the project,It has run without any issues,
Performing system checks...
System check identified no issues (0 silenced).
May 22, 2017 - 10:20:14
Django version 1.11.1, using settings 'callluge.settings'
Starting development server at http://127.0.0.1:8001/
Quit the server with CONTROL-C.
So far so good, Now my question is, how could I see this in browser, if i simply access http://127.0.0.1:8001/ browser shows "Unable to connect",
if my domain name is say "osho.com", how should see the project interface in browser.Please help.
Run your server on public ip address of server . 127.0.0.1 is a localhost and it will be available within the your system. outside the machine you can't access this ip address.
So you have to run the server on public ip address of server.
This issue might seem very trivial but please try to suggest a solution for this if possible.
I have deployed a django App on AWS ec2 host and I am able to run the following command successfully.
(venv)[ec2-user#ip-xxx-xx-xx-xx abc]$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
January 03, 2016 - 13:15:31
Django version 1.7.1, using settings 'abc.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But I am not able to access http://127.0.0.1:8000/ from the browser.
On googling it's suggesting to use nginx or gunicorn. I am not sure if nginx, gunicorn etc. are to be used for this.
Can someone please let me know how can this be accessed from browser ?
Thanks,
You need to open HTTP port in AWS instance menu.(all ports except ssh closed in AWS)
Go to your console.aws.amazon.com, then pick your instance and go to last menu item "security groups". It lauch wizard, click on "Inbound" in bottom menu, then "edit", and add HTTP or any port what you want :)
And be sure you using your public AWS IP, to open in browser
Add some screen for you, hope it help:
In order to archive this all you need to do 3 simple steps.
Go to the EC2 Console and open up the security group of your instance. go to inbound tab.
click Edit and then press add rule...add entry with type of Custom TCP Rule and port 8000..
Go to your Django project,your app and open up the settings.py script. List your IPv4 address in the allowed_hosts section.. Ex : ALLOWED_HOSTS=['public IPv4']'
Now in the console run command python manage.py runserver 0.0.0.0:8000...
Open any web browser(from any device) and open the link 'public IPv4':8000
No need any app servers like Apache, NginX..
#Baterson is right. You should open port 8000 for your server first.
Official document is here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html . It is highly detailed.