We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 1,611 Posts
    I have a nagging question that has been chewing away at the back of my brain for a long time now...

    On the host that we use for most of our sites, we need to enter the ip address of the database server in order to connect to it. Entering localhost doesn’t work. However this has always seemed essentially wrong to me, since I assume that means that the database traffic travels off the server before returning, which seems like it could potentially be a security risk and almost certainly is slower.

    What’s odd is that the ip address that we need to use is the same as the web server’s ip, which makes me think that the database server is in fact on the same machine, but for some reason we can’t access it that way.

    First question: Should I care? It works reliably this way. It just doesn’t seem like the "right" way to do it.

    Second question: Are there potential security issues of connecting to the database this way (e.g., sending the username and password), or is the traffic probably all resolved locally anyway?

    Third question: Is this unusual? Do many shared hosting setups require you to use the ip address instead of localhost? Should I harrass my host to change this?

    Thanks in advance for your replies.
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 25663 MODX Staff
      • 12,272 Posts
      Does the loopback 127.0.0.1 work?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 37550 ☆ A M B ☆
        • 711 Posts
        I always find using hostnames much better than IPs especially if you have to migrate all your users to a new network environment it would be a pain.

        Here’s some info on MYSQL security http://dev.mysql.com/doc/refman/5.0/en/security-against-attack.html

        I reckon if the web server IP is the same as MYSQL the hosting company has set MYSQL to listen on a specific IP and not localhost (127.0.0.1) I’ can’t see any logic in them doing this though, drop them an email to get it changed to bind to localhost aswell. smiley

        Aaron
          http://www.onesmarthost.co.uk
          UK MODX Hosting with love.
          • 33372
          • 1,611 Posts
          Quote from: rthrash at Apr 25, 2007, 02:45 PM

          Does the loopback 127.0.0.1 work?

          That’s a good question. And something i hadn’t tried before. Unfortunately the answer is no.

          There doesn’t seem to be anything on the MySQL site saying that conecting this way is a terrible awful no good very bad thing to do, so either I didn’t look hard enough or perhaps it’s not something I should be worrying about.

          Maybe I will email the host about this, though, since it still bugs me...
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 23802
            • 65 Posts
            why localhost doesn’t work if the website and mySQL located on the same server?
              • 33372
              • 1,611 Posts
              That’s exactly what I want to know!
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 37550 ☆ A M B ☆
                • 711 Posts
                Quote from: pr0ph3t at Apr 25, 2007, 09:28 PM

                why localhost doesn’t work if the website and mySQL located on the same server?

                IP Address binding is only set to the external IP.
                  http://www.onesmarthost.co.uk
                  UK MODX Hosting with love.