How Do I Access ESP32 Web Server From Anywhere?


Scott Campbell

Are you looking for a way to access your ESP32 web server from anywhere? Look no further!

In this tutorial, we will guide you through the process of setting up your ESP32 web server and accessing it remotely. So, let’s get started!

What is an ESP32 Web Server?

Firstly, let’s understand what an ESP32 web server is. The ESP32 is a powerful microcontroller that can be used for various IoT applications. It comes with built-in Wi-Fi capabilities, allowing it to connect to the internet and host a web server.

An ESP32 web server enables you to control and monitor your devices remotely. You can create a user-friendly interface using HTML, CSS, and JavaScript to interact with your connected devices.

Setting Up Your ESP32 Web Server

To set up your ESP32 web server, follow these steps:

  1. Install the Required Libraries: Start by installing the necessary libraries in your Arduino IDE. You will need the “ESPAsyncWebServer” library for handling HTTP requests and serving web pages.
  2. Connect Your ESP32: Connect your ESP32 board to your computer using a USB cable.
  3. Create a New Arduino Sketch: Open the Arduino IDE and create a new sketch.
  4. Add the Required Code: Copy and paste the code below into your sketch:


    const char* ssid = “YourWiFiSSID”;
    const char* password = “YourWiFiPassword”;

    AsyncWebServer server(80);

    void setup(){
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {

    server.on(“/”, HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, “text/html”, “

    Welcome to my ESP32 web server!



    void loop(){

    Make sure to replace `”YourWiFiSSID”` with your actual Wi-Fi SSID and `”YourWiFiPassword”` with your Wi-Fi password.

  5. Upload the Sketch: Upload the sketch to your ESP32 board by clicking on the upload button in the Arduino IDE.

Once uploaded, your ESP32 will connect to your Wi-Fi network and start hosting a web server. By default, it serves a simple web page displaying the message “Welcome to my ESP32 web server!”.

Accessing Your ESP32 Web Server Remotely

To access your ESP32 web server remotely, you need to perform port forwarding on your router. Here’s how you can do it:

  1. Find Your Router’s IP Address: Open a web browser and enter your router’s IP address in the address bar. You will usually find this information in the router’s manual or on its label.
  2. Login to Your Router: Enter the username and password for your router. If you haven’t changed them, try using the default credentials provided by the manufacturer.
  3. Navigate to Port Forwarding Settings: Look for an option called “Port Forwarding” or “Virtual Server” in your router’s settings. The exact location may vary depending on your router model.
  4. Add a New Port Forwarding Rule: Add a new rule by specifying the following details:

    – External Port: Choose a port number (e.g., 8080) that will be used to access your ESP32 web server from the internet.

    – Internal IP Address: Enter the local IP address of your ESP32 board. You can find this information in your router’s DHCP client list or by checking the serial monitor in the Arduino IDE. – Internal Port: Enter “80” as the internal port since your ESP32 web server is running on port 80. – Protocol: Select “TCP” as the protocol.

  5. Save and Apply the Changes: Once you have entered all the required details, save and apply the changes in your router’s settings.

That’s it! You have successfully set up port forwarding for your ESP32 web server. Now you can access it remotely by entering your public IP address followed by the chosen external port number (e., `http://your-public-ip:8080`) into a web browser.


Keep in mind that accessing your ESP32 web server remotely may pose security risks. It is recommended to implement additional security measures such as authentication and encryption to protect your devices and data.


In this tutorial, we learned how to set up an ESP32 web server and access it remotely. By following these steps, you can control and monitor your devices from anywhere in the world.

Remember to always prioritize security when exposing your devices to the internet. Enjoy exploring the possibilities of remote access with your ESP32!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy