Cannot access server on Virtual Box from the host?












1














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:



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?










share|improve this question





























    1














    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:



    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?










    share|improve this question



























      1












      1








      1







      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:



      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?










      share|improve this question















      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:



      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 15 at 3:33









      JakeGould

      30.9k1093137




      30.9k1093137










      asked Dec 15 at 3:32









      banu reddy

      82




      82






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer





















            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            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.






            share|improve this answer


























              0














              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.






              share|improve this answer
























                0












                0








                0






                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.






                share|improve this answer












                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 15 at 3:43









                JakeGould

                30.9k1093137




                30.9k1093137






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                     ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕