Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Python on sandbox: cannot connect to flask server

Python on sandbox: cannot connect to flask server

New Contributor

I used python on sandbox and launch the flask server using the following command

python app.py

* Running on http://0.0.0.0:5000/

however, when I go to http://sandbox.hortonworks.com:5000/, I got an "sandbox.hortonworks.com refused to connect." error.

I also try the http://192.168.227.129:5000/ and still cannot connect.

Any suggestion on how to connect to the 5000 port?

Thanks a lot.

Andy

10 REPLIES 10

Re: Python on sandbox: cannot connect to flask server

@Andy Liang

You will need to add port forwarding to your Sandbox environment. If you login to your sandbox and run netstat -pant from the cmd line, you should see port 5000 running, but it is not exposed external to the sandbox environment.

If you are using Virtualbox, you can edit these settings to add port 5000 to the port forwarding rules:

11865-screen-shot-2017-01-30-at-80535-am.png

Then add port 5000 (which is the default port for flask) to the list of already configured ports:

Name: Flask

Protocol: TCP

Host IP: 127.0.0.1

Host Port: 5000

Guest IP:

Guest Port: 5000

11866-screen-shot-2017-01-30-at-80542-am.png

Let me know if this helps.

Re: Python on sandbox: cannot connect to flask server

New Contributor

@Dan Zaratsian Thanks for your advice. I am using VMware, so I tried to following the following instruction http://www.virten.net/2013/03/how-to-setup-port-forwarding-in-vmware-workstation-9/

However, i cannot make it work. Did I miss anything?

11965-screenhunter-03-feb-01-0808.jpg

11966-screenhunter-04-feb-01-0819.jpg

11967-screenhunter-05-feb-01-0821.jpg

Re: Python on sandbox: cannot connect to flask server

@Andy Liang

Try to open your browser and go to: http://localhost:5000

Give that a try and let me know if it works.

When you port forward, you forward that port on to you local machine (or another specified host).

Re: Python on sandbox: cannot connect to flask server

New Contributor

@Dan Zaratsian I tried both http://127.0.0.1:5000/ and http://localhost:5000/ but have no luck.

Re: Python on sandbox: cannot connect to flask server

New Contributor
@Dan Zaratsian

Thanks a lot for helping me on this. It might be the bug of VMware Workstation Pro 12.1.0 that causes the issue. https://communities.vmware.com/thread/526445?tstart=0

Re: Python on sandbox: cannot connect to flask server

@Andy Liang

Hopefully you're not hitting that bug, but that's good to know.

Here's a good article I found: http://www.virtuatopia.com/index.php/VMware_Server_NAT_Configuration

Do you have a NAT based virtual network setup? If so, then you can try to add the port forwarding rules.

Hopefully you can get this working. As an alternative, if you are just getting started with the sandbox VM, you may want to consider using Virtualbox, since the port forwarding rules seem to be much easier to implement.

Re: Python on sandbox: cannot connect to flask server

New Contributor
@Dan Zaratsian

I didn't configure the docker in the VM, so port forwarding is not working. It's working after I configure the sandbox. I learned a lot after following your advice. Thanks a lot for your help,

Re: Python on sandbox: cannot connect to flask server

@Andy Liang Great to hear you got it working - happy to help out!

Re: Python on sandbox: cannot connect to flask server

Expert Contributor

@Andy Liang,

There is definitely additional port forwarding that needs to be done to make this work. If it is the VMware problem you are describing, I would think that 127.0.0.1:8080 would not work, either. If you are getting to Ambari on :8080, it doesn't sound like you are hitting the VMware bug you mentioned.

The first layer of virtualization is the VMware you are using. Did you add port forwarding for port 5000 into the VMware port forwarding rules? You will have to do that first in order to get this to work.

There is a second layer of virtualization in the sandbox that ALSO needs to have the port forwarded. That is within docker in the VM that is running on VMware. There is a very nice article at https://community.hortonworks.com/content/kbentry/65914/how-to-add-ports-to-the-hdp-25-virtualbox-sa... that shows how to do it with Virtualbox. It includes the port forwarding step you will do in VMware above, so you need to scroll down to the section that says “Login to the Sandbox VM” and start from there. BE CAREFUL, though, that you do the ‘docker commit sandbox sandbox’ that is mentioned in a note before you do the ‘docker rm sandbox’ or you will revert the sandbox to its initial state.

Once you have both of the forwarding rules in place, you should be able to hit port 5000.

John

Don't have an account?
Coming from Hortonworks? Activate your account here