0

I have an Apache server configured to serve files which works fine when I set Apache to listen on 127.0.0.1:* or 0.0.0.0:*. I can access the site from the local machines browser either with localhost or either of the above two IP addresses.

Trying to access from my phone, connected to the same network, I'm having issues.

I have tried binding Apache to my public IP Address and varying the listening ports. When I then enter my public IP in my phones browser (DuckDuckGo) the browser is stuck in a loading state.

I'm not sure how to get around this, my Apache error_log has no record of a connection attempt. I'm pretty new to web hosting so I'm wondering if there's something I'm missing. How should I fix this ?

Note: The Apache server is running on my laptop which is hotspotting from my phones mobile data. Not sure if this may be a factor in the issue. I'm also aware that static IPs are recommended for this type of thing, yet from my understanding this should work just fine with a dynamic IP.

Help is appreciated !

1 Answer 1

2

I have tried binding Apache to my public IP Address

Sockets can only be bound to an address that's directly assigned to the system (i.e. shows up in ip addr or ipconfig /all). But your public IP address isn't assigned to your computer – it's assigned to your phone. (Think of your phone's hotspot as a basic home router with NAT, it works exactly the same way.)

In any case, Apache doesn't really know nor care whether you're connecting to a public address – the router translates all packets (inbound and outbound) so that they always have the computer's own private address anyway.

More likely the phone doesn't actually forward incoming connections by default; it's a NAT router with no port-forwarding rules and no way to configure them.

In fact, if you're not very lucky, even your phone itself might not have a public IP address. Some mobile networks put all customers behind carrier-level NAT, and sometimes it's 1:1 NAT (allowing inbound connections) but sometimes it is the usual 1:many NAT (which does not).

Additionally, even if your phone does have a public IP address, some mobile networks just deliberately block all inbound connections. Partly as a security measure, and partly because they insist that you're not paying them for a plan which would let you host services.

(With some operators these are actually the two main reasons for getting a static IP address: it's not so much about having an address that's static, it's about having an address that isn't behind carrier-grade NAT, as well as implicitly asking the operator to allow inbound connections to that address.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .