Running ubuntu vagrant server won't show anything on debian local browser - python

I've done this multiple times and never had an issue.
I'm trying to run a website on vagrant (trusty64) through shh on my Debian 8 Jessie x64.
I have used the same Vagrantfile n times before and it always worked perfectly but for I don't know what reason, on my new laptop, when I enter (on vagrant server - tried with sudo and without):
vagrant up
vagrant ssh
cd /opt/site/
python manage.py runserver 0.0.0.0:8000
nothing happens in console. It shows the usual:
System check identified 1 issue (0 silenced).
October 28, 2015 - 10:16:41
Django version 1.8.4, using settings 'settings.development'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
and when I type the ip:port in my local browser it just say:
This webpage is not available
ERR_CONNECTION_REFUSED
Any workaround for this ?
My vagrant config file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 512
end
config.vm.box = "trusty64"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.network "private_network", ip: "192.168.100.10"
config.vm.synced_folder ".", "/opt/site"
config.vm.hostname = "alexander"
end
As a mention: I tried multiple ports and still nothing. More, I have the exactly same configuration on another pc and it works flawless.

If changing the port forwarding doesn't work.You might also need to change in the settings of virtual box from NAT to Bridged Adapter.

The firewall will block incoming traffix on port 8000, so you will have to forward that port. Try adding this this to the configuration. you're using:
config.vm.network "forwarded_port", guest: 8000, host: 8080
and then browse to http://192.168.100.10:8080 it should work.
Also dont forget to privision your box again, or even restart just to be sure.
vagrant reload --provision
Why it works on your other machine is a mystery to me. Maybe there is no firewall, or the port is already forwarded?

Related

I can't access scrapyd port 6800 from browser

I searched a lot on this, it may have a simple solution that I am missing.
I have setup scrapy + scrapyd on both my local machine and my server. They work both ok when I try as "scrapyd".
I can deploy to local without a problem, and I can access to localhost:6800 as well from the browser and I can run spiders on local.
After running scrapyd on remote, I try to deploy to http://remoteip:6800/ with the same as I did deploy locally,
I get,
Packing version 1500333306
Deploying to project "projectX" in http://remoteip:6800/addversion.json
Deploy failed: <urlopen error [Errno 111] Connection refused>
I also can't access http://remoteip:6800/ from my local PC, but I can access from ssh on remote PC (with curl)
I opened inbound and outbound connections on the remote server, what else I am missing?
Thanks
First check if its running or not, run curl localhost:6800 on the server where ScrapyD is running
Check if firewall is enabled
sudo ufw status
Ideally, just allow tcp connections to 6800instead of disabling firewall, to do so
sudo ufw allow 6800/tcp
sudo ufw reload
Check your scrapyd.conf please set
bind_address=0.0.0.0
instead of
bind_address=127.x.x.x
0.0.0.0 will make scrapyD accessible for incoming connections outside the server/instance, not only localhost.
Then stop scrapyD, I do killall scrapyd to stop scrapyd
Then restart scrapyD using command scrapyd
Note:
If you want to keep scrapyd running even after you disconnect from server, do this
nohup scrapyd >& /dev/null &
Also see my answer to set ScrapyD as a System Service
I know this answer may be late, but I hope it can help others like me.
From the official documentation, it will search the config file in these places:
/etc/scrapyd/scrapyd.conf (Unix)
c:\scrapyd\scrapyd.conf (Windows)
/etc/scrapyd/conf.d/* (in alphabetical order, Unix) scrapyd.conf
~/.scrapyd.conf (users home directory)
So you need to create a scrapyd.conf file, and put some configurations in it.
Here is an example configuration file with all the defaults from the the documentation:
[scrapyd]
eggs_dir = eggs
logs_dir = logs
items_dir =
jobs_to_keep = 5
dbs_dir = dbs
max_proc = 0
max_proc_per_cpu = 4
finished_to_keep = 100
poll_interval = 5.0
bind_address = 127.0.0.1
http_port = 6800
debug = off
runner = scrapyd.runner
application = scrapyd.app.application
launcher = scrapyd.launcher.Launcher
webroot = scrapyd.website.Root
[services]
schedule.json = scrapyd.webservice.Schedule
cancel.json = scrapyd.webservice.Cancel
addversion.json = scrapyd.webservice.AddVersion
listprojects.json = scrapyd.webservice.ListProjects
listversions.json = scrapyd.webservice.ListVersions
listspiders.json = scrapyd.webservice.ListSpiders
delproject.json = scrapyd.webservice.DeleteProject
delversion.json = scrapyd.webservice.DeleteVersion
listjobs.json = scrapyd.webservice.ListJobs
daemonstatus.json = scrapyd.webservice.DaemonStatus
And what you need to do is: change the bind_address to 0.0.0.0

In zulip dev environment, how can i access zulip's first dev web browser using run-dev.py in vagrant env but i can't access from global ip

I have some problem now using zulip dev-env ...
I did success-installation by Dev-env(using run-dev.py in vagrant env) in my Mac PC and then i could access the first-dev page successfully through my mac-pc's browser
But i have been trying to show the first page using Dev-dev in my cloud hosting service (like AWS or google Cloud hosting) for several days
but i could not access and could not show the first page by using global IP and browser
Which part must I change the setting environment?
(that is, I want to access my dev-env[using run-dev.py] by global IP
after that, i want to test... )
Now I am using a cloud hosting. Of course I opened port 9991 and etc...
I use vagrant env and succeed it in cloud host.
In vagrant ssh, I could access zulip by using curl 127.0.0.1:9991 and received a success message:
29/Sep/2016 00:42:04]"GET / HTTP/1.0" 302 0" from running console
but i cannot access it by host console like this
ai2#mrtalk:~/project/zulip$ curl 127.0.0.1:9991
curl: (7) Failed to connect to 127.0.0.1 port 9991: Connection refused
of course , i can't access http://182.162.90.79:9991/ through my pc browser
for this I tried like these
In zproject/dev_setting.py (I changed...these lines)
EXTERNAL_HOST = '0.0.0.0:9991' #orgin localhost but change 0.0.0.0
ALLOWED_HOSTS = ['localhost','182.162.90.79','0.0.0.0'] #orgin localhost but add + '182.162.90.79','0.0.0.0'
In Vagrantfile I changed this line:
config.vm.network "forwarded_port", guest: 9991, host: host_port, host_ip: 127.0.0.1, auto_correct: true
What is wrong with here? Or which part should I change my dev-setting?

Access django server on VirtualBox/Vagrant machine from host browser?

I have a Django web server on a VirtualBox/Vagrant machine running "bento/centos-6.7-i386".
I have followed this guide to create a Django project: https://docs.djangoproject.com/en/dev/intro/tutorial01/
I have a web server running at http://127.0.0.1:8000/ inside my guest machine. This is the first time I am running a Django web server. It is supposed to be a hello world app.
How can I access this web application from my host browser?
I tried adding this line - config.vm.network "private_network", ip: "55.55.55.5" in the vagrant file and then tried to run the python manage.py runserver 0.0.0.0:80 command as per 1 of the solutions explained in previous discussions by others but I couldn't access the site from my host browser using 55.55.55.5:8000.
How can I access the web server from my browser?
Following given is my Vagrant File:
# -- mode: ruby --
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-6.7-i386"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5000, host: 5000
config.vm.network "private_network", ip: "10.10.10.10"
end
You're forwarding port 8000 on the guest to 8000 on the host. Try:
python manage.py runserver 0:8000
Then in your browser visit: http://localhost:8000
That'll leave port 80 free if you end up wanting to run a web server for testing as well. Good luck!
if you are using below line in your Vagrantfile for port forwarding
config.vm.network "forwarded_port", guest: 8000, host: 8000
It means you will be able to access your guest application which running at port 8000 in your host browser at port 8000. so you will be able access by hitting http://127.0.0.1:8000 or http://localhost:8000 in your host.
why you are forcing your app to run on 0.0.0.0 ? .
it is not required , or if you want to access with guest IP address then there is no sense to use port forwarding.
if you changed this configuration in Vagrantfile after provision then don`t forget to reload
vagrant reload
I got a problem with Django and port forwarding insider VB.
Django doesn't allow external hosts to access it.
So change the start command to
python3 ./manage.py runserver 0.0.0.0:8000
and everything worked

Django Cannot Be Accessed From Localhost

It's kinda weird I cannot access django from localhost but I able to access it from local IP.
python manage.py runserver 0.0.0.0:8000
then when I try to access from
My host file
127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 gc.kis.scr.kaspersky-labs.com ff.kis.scr.kaspersky-labs.com ie.kis.scr.kaspersky-labs.com
0.0.0.0 gc.kis.scr.kaspersky-labs.com ff.kis.scr.kaspersky-labs.com ie.kis.scr.kaspersky-labs.com
I'm guessing something wrong with windows firewall or kaspersky,but I don't know what to do.
I've add exception to port 8000 and python.exe too
I cannot access localhost:8000 from my browser if I run python manage.py runserver
I don't know why that command cannot work in my laptop, but in my pc it just works.
====
ok, so my solution now is to use ipv6 and port 8000 which is
python manage.py runserver [::]:8000
Just try http://0.0.0.0:8000 instead of localhost:8000
Default localhost value is http://127.0.0.1
If you see the runerver result you have :
starting developement server at http://0.0.0.0:8000
Because you told that django server start at http://0.0.0.0:8000 when you run this command :
python manage.py runserver 0.0.0.0:8000
I'm also beginner to django, but I needed following things in order to run the server:
In settings.py, added ALLOWED_HOSTS as
ALLOWED_HOSTS = [
'elearning.com'
]
where elearning.com is my hostname. You can have multiple hosts separated with comma.
Used following command to run the server:
python manage.py runserver [::]:8000 or python manage.py runserver 0.0.0.0:8000 or python manage.py runserver 0:8000.
It will now listen to all interfaces. Read Django doc here.
Browsed to given hostname. In my case, it is http://elearning.com:8000/
I tried writing IP in ALLOWED_HOSTS but it didn't work, I could not open http://192.168.x.x:8000 in browser. Can anyone please correct me?
simply execute
python manage.py runserver
automatically you can access by localhost and for the extern access you could have access if not are it's locked the port 8000, for access to django admin use the next url:
http://127.0.0.1:8000/admin/
How your host file end up like this ?? . Can you test something.
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
My host file see everything is commented out. Can you do the same with your hosts file and give it a Try .. .
In the settings.py file in your project folder,
add '0.0.0.0' to the allowed host list.
Then save the file and run the command.Guess will work.

how to run the django server on hostname?

I wanted to run Django server on a hostname in the local system. Django has its own server ... that runs on the localhost:8000 i just want it to run on
cpanel-django.django-project.com:8000
I tried using:
python manage.py runserver cpanel-django.django-project.com:8000
i am getting this error:
Validating models...
0 errors found
March 06, 2014 - 06:21:24
Django version 1.6.2, using settings 'moclient.settings'
Starting development server at http://cpanel-django.django-project.com:8383/
Quit the server with CONTROL-C.
Error: [Errno -5] No address associated with hostname
You need to edit the hosts file and rename localhost to cpanel-django.django-project.com.
For every host name there is mapping of IP address in your system so that you don't need to worry about IP address, you just need to remember host name.
How to add Host name in your system?
Check this wiki: Host file content
Where to find the file in your system?
Location of file in different system is mentioned here
For windows , you can make an entry in hosts file , located in
C:\Windows\System32\drivers\etc\hosts
and update the file with
127.0.0.1 cpanel-django.django-project.com:8383
If you are running on port 80 ,
127.0.0.1 cpanel-django.django-project.com

Categories

Resources