Support Questions
Find answers, ask questions, and share your expertise

Python on sandbox: cannot connect to flask server


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


* Running on

however, when I go to, I got an " refused to connect." error.

I also try the and still cannot connect.

Any suggestion on how to connect to the 5000 port?

Thanks a lot.



@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:


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

Name: Flask

Protocol: TCP

Host IP:

Host Port: 5000

Guest IP:

Guest Port: 5000


Let me know if this helps.


@Dan Zaratsian Thanks for your advice. I am using VMware, so I tried to following the following instruction

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




@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).


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

@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.

@Andy Liang

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

Here's a good article I found:

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.

@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,

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

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 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 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.