Cannot access server on Virtual Box from the host?
I am running Ubuntu 18.04.1 in Virtual Box on MacOS. I setup a localhost
server in Ubuntu using Python Flask running on http://127.0.0.1:5000/
I am trying to access this localhost from my Mac, but can’t. I used Bridge type connection for the virtual box so that my mac and the virtual box both could have IP address. Here is a picture of my virtual box network settings:
Ubuntu address is 192.168.1.169
. When I type 192.168.1.169:5000
I can't get anything, it never ends loading. I also tried opening Ubuntu firewall to port 5000
. No luck. Why is this happening?
networking ubuntu virtualbox virtual-machine
add a comment |
I am running Ubuntu 18.04.1 in Virtual Box on MacOS. I setup a localhost
server in Ubuntu using Python Flask running on http://127.0.0.1:5000/
I am trying to access this localhost from my Mac, but can’t. I used Bridge type connection for the virtual box so that my mac and the virtual box both could have IP address. Here is a picture of my virtual box network settings:
Ubuntu address is 192.168.1.169
. When I type 192.168.1.169:5000
I can't get anything, it never ends loading. I also tried opening Ubuntu firewall to port 5000
. No luck. Why is this happening?
networking ubuntu virtualbox virtual-machine
add a comment |
I am running Ubuntu 18.04.1 in Virtual Box on MacOS. I setup a localhost
server in Ubuntu using Python Flask running on http://127.0.0.1:5000/
I am trying to access this localhost from my Mac, but can’t. I used Bridge type connection for the virtual box so that my mac and the virtual box both could have IP address. Here is a picture of my virtual box network settings:
Ubuntu address is 192.168.1.169
. When I type 192.168.1.169:5000
I can't get anything, it never ends loading. I also tried opening Ubuntu firewall to port 5000
. No luck. Why is this happening?
networking ubuntu virtualbox virtual-machine
I am running Ubuntu 18.04.1 in Virtual Box on MacOS. I setup a localhost
server in Ubuntu using Python Flask running on http://127.0.0.1:5000/
I am trying to access this localhost from my Mac, but can’t. I used Bridge type connection for the virtual box so that my mac and the virtual box both could have IP address. Here is a picture of my virtual box network settings:
Ubuntu address is 192.168.1.169
. When I type 192.168.1.169:5000
I can't get anything, it never ends loading. I also tried opening Ubuntu firewall to port 5000
. No luck. Why is this happening?
networking ubuntu virtualbox virtual-machine
networking ubuntu virtualbox virtual-machine
edited Dec 15 at 3:33
JakeGould
30.9k1093137
30.9k1093137
asked Dec 15 at 3:32
banu reddy
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I am not familiar with Python Flask, but that said if you are running the server off of 127.0.0.1
you are simply restricting it to the localhost
and nothing else. This is not a Python Flask specific concept but a general networking concept.
For most any application running on a server, to get that application to be available on the network on any setup, you need to run the application on the IP address of 0.0.0.0
. More details here on this other answer found on Stack Overflow. And as explained clearly in the official Python Flask Quickstart guide:
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
If you don’t want an application to be available on all interfaces, you would need to assign your machine a static IP address and then set that flask run --host=xxx.xxx.xxx.xxx
to use that specific static IP address. But for something like this—where you are running it on a router via DHCP for personal development use, binding to 0.0.0.0
is not a big concern.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1383749%2fcannot-access-server-on-virtual-box-from-the-host%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am not familiar with Python Flask, but that said if you are running the server off of 127.0.0.1
you are simply restricting it to the localhost
and nothing else. This is not a Python Flask specific concept but a general networking concept.
For most any application running on a server, to get that application to be available on the network on any setup, you need to run the application on the IP address of 0.0.0.0
. More details here on this other answer found on Stack Overflow. And as explained clearly in the official Python Flask Quickstart guide:
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
If you don’t want an application to be available on all interfaces, you would need to assign your machine a static IP address and then set that flask run --host=xxx.xxx.xxx.xxx
to use that specific static IP address. But for something like this—where you are running it on a router via DHCP for personal development use, binding to 0.0.0.0
is not a big concern.
add a comment |
I am not familiar with Python Flask, but that said if you are running the server off of 127.0.0.1
you are simply restricting it to the localhost
and nothing else. This is not a Python Flask specific concept but a general networking concept.
For most any application running on a server, to get that application to be available on the network on any setup, you need to run the application on the IP address of 0.0.0.0
. More details here on this other answer found on Stack Overflow. And as explained clearly in the official Python Flask Quickstart guide:
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
If you don’t want an application to be available on all interfaces, you would need to assign your machine a static IP address and then set that flask run --host=xxx.xxx.xxx.xxx
to use that specific static IP address. But for something like this—where you are running it on a router via DHCP for personal development use, binding to 0.0.0.0
is not a big concern.
add a comment |
I am not familiar with Python Flask, but that said if you are running the server off of 127.0.0.1
you are simply restricting it to the localhost
and nothing else. This is not a Python Flask specific concept but a general networking concept.
For most any application running on a server, to get that application to be available on the network on any setup, you need to run the application on the IP address of 0.0.0.0
. More details here on this other answer found on Stack Overflow. And as explained clearly in the official Python Flask Quickstart guide:
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
If you don’t want an application to be available on all interfaces, you would need to assign your machine a static IP address and then set that flask run --host=xxx.xxx.xxx.xxx
to use that specific static IP address. But for something like this—where you are running it on a router via DHCP for personal development use, binding to 0.0.0.0
is not a big concern.
I am not familiar with Python Flask, but that said if you are running the server off of 127.0.0.1
you are simply restricting it to the localhost
and nothing else. This is not a Python Flask specific concept but a general networking concept.
For most any application running on a server, to get that application to be available on the network on any setup, you need to run the application on the IP address of 0.0.0.0
. More details here on this other answer found on Stack Overflow. And as explained clearly in the official Python Flask Quickstart guide:
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
If you don’t want an application to be available on all interfaces, you would need to assign your machine a static IP address and then set that flask run --host=xxx.xxx.xxx.xxx
to use that specific static IP address. But for something like this—where you are running it on a router via DHCP for personal development use, binding to 0.0.0.0
is not a big concern.
answered Dec 15 at 3:43
JakeGould
30.9k1093137
30.9k1093137
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1383749%2fcannot-access-server-on-virtual-box-from-the-host%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown