Accessing your local server remotely is hard, and it's harder if you don't have the right tools. Developers often use tunneling services like Ngrok, LocalTunnel or Cloudflared etc to expose their localhost over the internet. But these all come with limitations, specially the free plans where they put bandwidth limits or don't allow to use custom domains which is usually a dealbreaker.
In this tutorial, we'll go over how to get an alternative VPN up and running that's free, secure, and doesn't require you to be able to connect via tunneling. ZeroTier will allow you to join your devices together as if they were on the same local network no matter where they are.
Why ZeroTier?
ZeroTier creates a virtual LAN (Local Area Network) so that you can connect your devices with internet as if they were on the same network. With this, you will be able to access localhost from another computer or device remotely without caring about bandwidth limit or network instability that is caused by tunneling service.
How to set it up?
Here’s a step-by-step guide on how to set it up.
Step 1: Install ZeroTier
First, you will need to install ZeroTier on your local machine as well as on the remote machines that you will be connecting to. ZeroTier is available for all major platforms (Windows, macOS, Linux, Android, iOS) which makes it suitable for a variety of different machines.
Step 2: Create or Join a ZeroTier Network
To connect devices, you need a Network ID. The Network ID is what lets different devices join the same virtual network. You can create your own network or join someone else’s if they share their Network ID with you.
Creating a Network
- After logging into the ZeroTier dashboard, you’ll see an option to Create a New Network.
- Click on the button, and a unique Network ID will be generated for you.
- Share this Network ID with anyone you want to give access to your local server. Each device that joins will need this ID to connect.
Joining a Network
- To join a network, enter the Network ID you’ve received from another ZeroTier user into the app.
- The network admin will need to approve your connection request before you’re fully connected. (If the network is private)
Step 3: Connect your devices to ZeroTier
To access your localhost from other devices you have to make sure that all your devices are on the same ZeroTier network even if they are on different local networks.
- Join the Same ZeroTier Network:
- On each device, open the ZeroTier application.
- Enter the Network ID of the ZeroTier network you created earlier, this is required so that both instances will be connect to the same virtual network.
- If the network is public or open, then there is no need for further authentication to connect to the network
- Confirmation of Connection (For private connection):
- Open the ZeroTier dashboard in your web browser.
- Under the Members tab, you’ll see a list of devices. Click the auth checkbox to approve their connection.
- Connected state:
- Once approved, the devices will show up as connected in the ZeroTier dashboard.
- Each device will receive a unique virtual IP address within the ZeroTier network, allowing them to communicate securely.
Step 4: Connect to Your Localhost
Now that you have ZeroTier set up, you can connect to your local server remotely.
- Find the IP address assigned to your machine within the ZeroTier network. It will look like a local IP (e.g., 192.168.X.X).
- Use this IP to access services hosted on your localhost. for example if you have an app running on port 8000 on your local machine, you would access it from a remote device via http://192.168.X.X:8000.
This works with SSH and remote desktop or any service you want to reach on your machine too.
Note: it will only work while both machines are connected to the ZeroTier network, if ZeroTier is off all connection will be lost
Why not Ngrok?
Unlike traditional tunneling services (e.g., Ngrok) ZeroTier doesn't use temporary URLs or restrict bandwidth. The main benefits are:
- Persistent Connections: Once things are connected to the network, they stay connected as long as the service is running. No need to continually remake tunnels.
- No Bandwidth Limits: With ZeroTier being a virtual LAN based service there isn’t bandwidth caps some free tunneling services will have.
- Privacy & Security: ZeroTier makes sure that all the traffic between the devices is secure using encyrption.
Conclusion
ZeroTier is a great solution if you want to remote access your localhost or local server without using services such as Ngrok. Connections are secure, reliable and there are no bandwidth and domain limits to worry about, perfect for developers or teams working remotely.
If you found this guide useful, please share it with others who may also benefit from it. Any questions or feedback? Let me know in the comments section below and I'll get back to you!
No comments:
Post a Comment