Running local web servers

Run a local web server on your local machine to test your API integrations.

Why run a local web server?

To test asynchronous requests and code written in a server-side programming language (such as PHP), you need access to a developer server or the ability to run a local web server (localhost). Running a local web server lets you render webpages locally in a browser without making them publicly available to other people.

Test Square APIs with a local web server

To enable development and testing on local machines, some Square APIs have reduced security requirements when calls are made from localhost. For example, the Square Payment Form iframe will not load on HTTP websites unless they are served on localhost. To take advantage of these reduced security requirements when testing, you must serve local pages using the "localhost" keyword instead of an explicit IP address (e.g.,

Some programming language interpreters include a built-in web server that you can use for development and testing purposes. To bring up a built-in web server:

  1. Open the Mac Terminal or Windows Command Prompt.
  2. Navigate to the root folder containing the code you want to test.
  3. Enter the language-specific command from the table below.
Language Local web server command Default URL
PHP $ php -S localhost:8000 http://localhost:8000
Rails $ rails server http://localhost:3000
Python $ python -m SimpleHTTPServer 8000 (Python 2)
$ python -m http.server 8000 (Python 3)
< Testing Square APIs with Postman
Sandbox Test Values >

Ask for help on Stack Overflow or join our Slack channel