Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

Using the local development server

You can use the local development server to simulaterunning your App Engine application in production as well as use it toaccess App Engine bundled services.

The simulated environment enforces some sandbox restrictions, such as restrictedsystem functions and Python 2 module imports, but not others, likerequest timeouts or quotas.

The local development server also simulates the services provided by thelibraries in the SDK for App Engine, including Datastore, Memcache, andTask Queues, by performing their tasks locally. When your application isrunning in the development server, you can still make remote API calls to theproduction infrastructure using Google APIs HTTP endpoints.

Before you begin

Since Python 2.7 has reached theend of support, you can no longer use thelatest version ofdev_appserver.py to locally run yourapplications. To download an archived version ofdevapp_server.py, follow thesesteps:

  1. From thearchive, download the zipped folder that contains thedev_appserver.py server for runtimes that have reached the end of support.

  2. Extract the directory's contents to your local file system, such as to your/home directory. You can finddev_appserver.py in thegoogle_appengine/ directory.

Set up the local development server

To run the local development server tool, you must set up the following:

  1. Verify that you have installed a Python 2 interpreter of version 2.7.12 or later.

  2. Set theDEVAPPSERVER_ROOT environment variable in your shell tothe path of your Python 2 interpreter.

Run the local development server

Note: Thedev_appserver tool does not support development of Python 3 apps onWindows.

Aftersetting up the local development server and creating theapp.yamlconfiguration file for your app, you can use thedev_appserver.py command torun your app locally.

To start the local development server:

  1. In the directory that contains yourapp.yaml configuration file, runthedev_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.pyapp.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 thearchived version ofdevapp_server.py.

    To learn more about thedev_appserver.py command options, seeLocal development server options.

  2. The local development server is now running and listening for requests. Youcan visithttp://localhost:8080/ in your webbrowser to see the app in action.

    If you specified a custom port with the--port option, remember to openyour browser to that port.

To stop the local server from the command line, press the following:

  • macOS or Linux:Control+C
  • Windows:Control+Break

Specify application IDs

To access your App ID in the local server, for example to spoof an emailaddress, use theget_application_id()function. To get the hostname of the running app, use theget_default_version_hostname()function.

Detecting application runtime environment

To determine whether your code is running in production or in the localdevelopment server, you can check the value of theSERVER_SOFTWARE environmentvariable:

ifos.getenv('SERVER_SOFTWARE','').startswith('Google App Engine/'):# Productionelse:# Local development server

Using the local Datastore

Note: We are migrating the local development environment to use theCloud Datastore Emulator, For moreinformation about this change, see themigration guide.

The local development server simulates the App Engine datastore using alocal file that persists between invocations of the local server.

For more information on indexes andindex.yaml, see theDatastore IndexesandDatastore IndexConfiguration pages.

Browse the local Datastore

If your app has written data to your local Datastore using the local developmentserver, you can browse it in the local development console.

To browse local Datastore:

  1. Start the development server.

  2. Access theDatastore Viewer in thelocal development console. (The URL ishttp://localhost:8000/datastore.)

  3. View your local Datastore contents.

Specify the ID allocation policy

For production App Engine, you can set the Datastore toautomatically generate entity IDs.

Although the auto ID assignment policies for the production server arecompletely different than those used by the development server, you can also setthe automatic ID allocation policy for the local server.

To specify the automatic ID assignment policy, use the--auto_id_policyoption:

python2DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py--auto_id_policy=sequential

Replace:

  • DEVAPPSERVER_ROOT with the path to the folder where youextract thearchived version ofdevapp_server.py.

  • --auto_id_policy with one of the following:

    • scattered when (default) IDs are assigned from a non-repeating sequence ofapproximately uniformly distributed integers.
    • sequential when IDs are assigned from the sequence of consecutive integers.
Note: Your app should make no assumptions about the sequence of automatic IDsassigned in production.

Clear the local Datastore

To clear the local datastore for an application, invoke the local developmentserver as follows:

python2DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py--clear_datastore=yesapp.yaml

ReplaceDEVAPPSERVER_ROOT with the path to the folder where youextract thearchived version ofdevapp_server.py.

Change local Datastore location

To change the location used for the datastore file, use the--datastore_pathoption:

python2DEVAPPSERVER_ROOT/google_appengine/dev_appserver.py--datastore_path=/tmp/myapp_datastoreapp.yaml

ReplaceDEVAPPSERVER_ROOT with the path to the folder where you extract thearchived version ofdevapp_server.py.

Use the Users service

App Engine provides aUsers Service to simplifyauthentication and authorization for your application. The local developmentserversimulates the behavior of GoogleAccountswith its own sign-in and sign-out pages. While running under the localdevelopment server, theusers.create_login_urlandusers.create_logout_urlfunctions return URLs for/_ah/login and/_ah/logout on the local server.

Use Mail

The local development server can send email for calls to the App Enginemail service using either an SMTP server or a local installation ofSendmail.

Using SMTP

To enable mail support with an SMTP server, invokedev_appserver.py asfollows::

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 youextract thearchived version ofdevapp_server.py.
  • --smtp_host,--smtp_port,--smtp_user and--smtp_password options with your own configuration values.

Using Sendmail

To enable mail support with Sendmail, invokedev_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 youextract thearchived version ofdevapp_server.py.

The local server will use thesendmail command to send email messages withyour installation's default configuration.

Note: If you don't invokedev_appserver.py with either SMTP or Sendmail asdescribed, then attempts to send email from your application will donothing, 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, thelocal development server makes the request directly from your computer. TheURL Fetch behavior on the local server may differ from productionApp Engine if you use a proxy server for accessing websites.

Use the Interactive Console

TheInteractive Console allows developers to enter arbitrary Python codeinto a web form and execute it inside their app's environment; it provides thesame access to the application's environment and services as a .py file insidethe application itself.

Important: If you specify the--host argument when you start the localserver instead of using the default address, the Interactive Console is disabledto prevent someone remotely executing arbitrary Python code on your computer.You can bypass this and re-enable the Interactive Console by starting thedevelopment server using the--enable_console argument.

To use the Interactive Console:

  1. Start the development server.

  2. Access theInteractive console in thein the local development console. (The URL ishttp://localhost:8000/console.)

  3. Enter any Python code you'd like to run in the text area, then submit theform to execute it. For example the following code will add a Datastore entitycalledGreeting with text content ofHello:

    fromgoogle.appengine.extimportndbclassGreeting(ndb.Model):content=ndb.TextProperty()e=Greeting(content="Hello")e.put()

Debug with the Python debugger

To use thePython debugger (pdb):

  1. Add the following line into your code:

    importpdb;pdb.set_trace();

    dev_appserver will break at this point and drop into thepdb REPL(read–eval–print loop), allowing you to debug your code from the commandline.

  2. If your application makes multiple simultaneous requests that invokepdb.set_trace(), multiple debugging sessions will start concurrently, eachof which sends output toSTDOUT. To avoid this, serialize your requests bydisabling thedev_appserver multi-threading and multi-processing support,as follows:

    1. Disable multi-threading for:

      • All services using the--threadsafe_override=false flag.
      • One service using the--threadsafe_override=<SERVICENAME>:false flag.
      • Multiple services using the--threadsafe_override=<SERVICE1NAME>:false,<SERVICE2NAME>:false flag.
    2. Disable multi-processing for:

      • All services using the--max_module_instances=1 flag.
      • One service using the--max_module_instances=<SERVICENAME>:1 flag.
      • Multiple services using the--max_module_instances=<SERVICE1NAME>:1,<SERVICE2NAME>:1 flag.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.