---
id: running-webserver
title: Run a web server
description: Run an HTTP server inside your Actor for monitoring or serving content during execution.
---

import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock';

import WebserverExample from '!!raw-loader!roa-loader!./code/07_webserver.py';

In this guide, you'll learn how to run a web server inside your Apify Actor. This is useful for monitoring Actor progress, creating custom APIs, or serving content during the Actor run.

## Introduction

Each Actor run on the Apify platform is assigned a unique hard-to-guess URL (for example `https://8segt5i81sokzm.runs.apify.net`), which enables HTTP access to an optional web server running inside the Actor run's container.

The URL is available in the following places:

- In Apify Console, on the Actor run details page as the **Container URL** field.
- In the API as the `container_url` property of the [Run object](https://docs.apify.com/api/v2#/reference/actors/run-object/get-run).
- In the Actor as the `Actor.configuration.container_url` property.

The web server running inside the container must listen at the port defined by the `Actor.configuration.container_port` property. When running Actors locally, the port defaults to `4321`, so the web server will be accessible at `http://localhost:4321`.

## Example Actor

The following example shows how to start a simple web server in your Actor, which will respond to every GET request with the number of items that the Actor has processed so far:

<RunnableCodeBlock className="language-python" language="python">
    {WebserverExample}
</RunnableCodeBlock>

## Conclusion

In this guide, you learned how to run a web server inside your Apify Actor. By leveraging the container URL and port provided by the platform, you can expose HTTP endpoints for monitoring, reporting, or serving content during Actor execution. If you have questions or need assistance, feel free to reach out on our [GitHub](https://github.com/apify/apify-sdk-python) or join our [Discord community](https://discord.com/invite/jyEM2PRvMU).

## Additional resources

- [Apify templates: Standby Python project](https://apify.com/templates/python-standby)
