Stay organized with collections Save and categorize content based on your preferences.
You can use the local development server to simulate running your App Engine application in production as well as use it to access App Engine bundled services.
The simulated environment enforces some sandbox restrictions, such as restricted system functions and Python 2 module imports, but not others, like request timeouts or quotas.
The local development server also simulates the services provided by the libraries in the SDK for App Engine, including Datastore, Memcache, and Task Queues, by performing their tasks locally. When your application is running in the development server, you can still make remote API calls to the production infrastructure using Google APIs HTTP endpoints.
Before you beginSince Python 2.7 has reached the end of support, you can no longer use the latest version of dev_appserver.py
to locally run your applications. To download an archived version of devapp_server.py
, follow these steps:
From the archive, download the zipped folder that contains the dev_appserver.py
server for runtimes that have reached the end of support.
Extract the directory's contents to your local file system, such as to your /home
directory. You can find dev_appserver.py
in the google_appengine/
directory.
To run the local development server tool, you must set up the following:
Verify that you have installed a Python 2 interpreter of version 2.7.12 or later.
Set the DEVAPPSERVER_ROOT
environment variable in your shell to the path of your Python 2 interpreter.
dev_appserver
tool does not support development of Python 3 apps on Windows.
After setting up the local development server and creating the app.yaml
configuration file for your app, you can use the dev_appserver.py
command to run your app locally.
To start the local development server:
In the directory that contains your app.yaml
configuration file, run the dev_appserver.py
command.
Specify the directory path to your app, for example:
python2 [DEVAPPSERVER_ROOT]/google_appengine/dev_appserver.py [PATH_TO_YOUR_APP]
Alternatively, you can specify the configuration file of a specific service, for example:
python2 [DEVAPPSERVER_ROOT]/google_appengine/dev_appserver.py app.yaml
To change the port, you include the --port
option:
python2 [DEVAPPSERVER_ROOT]/google_appengine/dev_appserver.py --port=9999 [PATH_TO_YOUR_APP]
Replace [DEVAPPSERVER_ROOT]
with the path to the folder where you extract the archived version of devapp_server.py
.
To learn more about the dev_appserver.py
command options, see Local development server options.
The local development server is now running and listening for requests. You can visit http://localhost:8080/ in your web browser to see the app in action.
If you specified a custom port with the --port
option, remember to open your browser to that port.
To stop the local server from the command line, press the following:
To access your App ID in the local server, for example to spoof an email address, use the get_application_id()
function. To get the hostname of the running app, use the get_default_version_hostname()
function.
To determine whether your code is running in production or in the local development server, you can check the value of the SERVER_SOFTWARE
environment variable:
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Production
else:
# Local development server
Using the local Datastore Note: We are migrating the local development environment to use the Cloud Datastore Emulator, For more information about this change, see the migration guide.
The local development server simulates the App Engine datastore using a local file that persists between invocations of the local server.
For more information on indexes and index.yaml
, see the Datastore Indexes and Datastore Index Configuration pages.
If your app has written data to your local Datastore using the local development server, you can browse it in the local development console.
To browse local Datastore:
Access the Datastore Viewer in the local development console. (The URL is http://localhost:8000/datastore
.)
View your local Datastore contents.
For production App Engine, you can set the Datastore to automatically generate entity IDs.
Although the auto ID assignment policies for the production server are completely different than those used by the development server, you can also set the automatic ID allocation policy for the local server.
To specify the automatic ID assignment policy, use the --auto_id_policy
option:
python2 DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py --auto_id_policy=sequential
Replace:
DEVAPPSERVER_ROOT with the path to the folder where you extract the archived version of devapp_server.py
.
--auto_id_policy
with one of the following:
scattered
when (default) IDs are assigned from a non-repeating sequence of approximately uniformly distributed integers.sequential
when IDs are assigned from the sequence of consecutive integers.To clear the local datastore for an application, invoke the local development server as follows:
python2 DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py --clear_datastore=yes app.yaml
Replace DEVAPPSERVER_ROOT with the path to the folder where you extract the archived version of devapp_server.py
.
To change the location used for the datastore file, use the --datastore_path
option:
python2 DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py --datastore_path=/tmp/myapp_datastore app.yaml
Replace DEVAPPSERVER_ROOT with the path to the folder where you extract the archived version of devapp_server.py
.
App Engine provides a Users Service to simplify authentication and authorization for your application. The local development server simulates the behavior of Google Accounts with its own sign-in and sign-out pages. While running under the local development server, the users.create_login_url
and users.create_logout_url
functions return URLs for /_ah/login
and /_ah/logout
on the local server.
The local development server can send email for calls to the App Engine mail service using either an SMTP server or a local installation of Sendmail.
Using SMTPTo enable mail support with an SMTP server, invoke dev_appserver.py
as follows::
python2 [DEVAPPSERVER_ROOT]/google_appengine/dev_appserver.py --smtp_host=smtp.example.com --smtp_port=25 \
--smtp_user=ajohnson --smtp_password=k1tt3ns [PATH_TO_YOUR_APP]
Replace:
[DEVAPPSERVER_ROOT]
with the path to the folder where you extract the archived version of devapp_server.py
.--smtp_host
, --smtp_port
, --smtp_user
and --smtp_password
options with your own configuration values.To enable mail support with Sendmail, invoke dev_appserver.py
as follows:
python2 [DEVAPPSERVER_ROOT]/google_appengine/dev_appserver.py --enable_sendmail=yes [PATH_TO_YOUR_APP]
Replace [DEVAPPSERVER_ROOT]
with the path to the folder where you where you extract the archived version of devapp_server.py
.
The local server will use the sendmail
command to send email messages with your installation's default configuration.
dev_appserver.py
with either SMTP or Sendmail as described, then attempts to send email from your application will do nothing, but the attempt will appear successful in your application. Use URL Fetch
When your application uses the URL fetch API to make an HTTP request, the local development server makes the request directly from your computer. The URL Fetch behavior on the local server may differ from production App Engine if you use a proxy server for accessing websites.
Use the Interactive ConsoleThe Interactive Console allows developers to enter arbitrary Python code into a web form and execute it inside their app's environment; it provides the same access to the application's environment and services as a .py file inside the application itself.
Important: If you specify the--host
argument when you start the local server instead of using the default address, the Interactive Console is disabled to prevent someone remotely executing arbitrary Python code on your computer. You can bypass this and re-enable the Interactive Console by starting the development server using the --enable_console
argument.
To use the Interactive Console:
Access the Interactive console in the in the local development console. (The URL is http://localhost:8000/console
.)
Enter any Python code you'd like to run in the text area, then submit the form to execute it. For example the following code will add a Datastore entity called Greeting
with text content of Hello
:
from google.appengine.ext import ndb
class Greeting(ndb.Model):
content = ndb.TextProperty()
e = Greeting(content="Hello")
e.put()
To use the Python debugger (pdb
):
Add the following line into your code:
import pdb; pdb.set_trace();
dev_appserver
will break at this point and drop into the pdb
REPL (read–eval–print loop), allowing you to debug your code from the command line.
If your application makes multiple simultaneous requests that invoke pdb.set_trace()
, multiple debugging sessions will start concurrently, each of which sends output to STDOUT
. To avoid this, serialize your requests by disabling the dev_appserver
multi-threading and multi-processing support, as follows:
Disable multi-threading for:
--threadsafe_override=false
flag.--threadsafe_override=<SERVICENAME>:false
flag.--threadsafe_override=<SERVICE1NAME>:false,<SERVICE2NAME>:false
flag.Disable multi-processing for:
--max_module_instances=1
flag.--max_module_instances=<SERVICENAME>:1
flag.--max_module_instances=<SERVICE1NAME>:1,<SERVICE2NAME>:1
flag.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-18 UTC."],[[["The local development server simulates the App Engine environment, allowing you to test your application and access bundled services like Datastore, Memcache, and Task Queues, locally."],["To use the local development server with Python 2 applications, you must download an archived version of `dev_appserver.py` since Python 2 is no longer supported."],["You can run your application locally using the `dev_appserver.py` command, specifying your application's directory or `app.yaml` configuration file, and you can also customize options such as the port."],["The local development server provides features like simulating the Users service, sending emails, and browsing the local Datastore, and can also be used to detect if the application is running locally or in production by checking the `SERVER_SOFTWARE` environment variable."],["The Interactive Console and the Python debugger (`pdb`) are available tools to test code in the local environment, with the option to disable multithreading and multiprocessing in order to avoid conflicts with concurrent debugging sessions."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4