Railway

Deploy Postcodes.io

Self hosted postcodes.io using the official Docker containers

Deploy Postcodes.io

Just deployed

/var/lib/postgresql/data

Just deployed

Deploy and Host Postcodes.io on Railway

Postcodes.io is a free, open-source HTTP API for UK postcode and geolocation lookups, maintained by Ideal Postcodes. It returns latitude, longitude, electoral wards, parliamentary constituencies, NHS regions, census areas, and dozens of other fields for every UK postcode, drawing from the ONS Postcode Directory (ONSPD) dataset.

About Hosting Postcodes.io

This template deploys two services: a PostgreSQL + PostGIS database preloaded with the full ONSPD dataset, and the Node.js HTTP API that queries it. The database image restores its preloaded dump on first boot — expect 60–90 seconds before the API starts returning real data. The dataset is persisted on a Railway volume so subsequent deploys skip the restore. The API service is exposed on a public domain; the database stays on Railway's private network. ONSPD is updated quarterly by the ONS, and the upstream Docker image is rebuilt whenever a new release lands.

Common Use Cases

  • Postcode autocomplete and validation in web forms or checkout flows
  • Reverse geocoding — turning latitude/longitude pairs back into nearby postcodes
  • Enriching customer records with administrative geographies (council ward, parliamentary constituency, NHS region) for analytics or segmentation

Dependencies for Postcodes.io Hosting

  • PostgreSQL with the PostGIS extension (bundled into the database image)
  • A persistent Railway volume to hold the loaded postcode dataset (~600 MB)

Deployment Dependencies

Implementation Details

Once deployed, query the API at your public Railway domain:

```bash

Lookup a single postcode

curl https://your-app.up.railway.app/postcodes/SW1A1AA

Bulk lookup

curl -X POST https://your-app.up.railway.app/postcodes
-H "Content-Type: application/json"
-d '{"postcodes":["SW1A1AA","M11AE","EH11YZ"]}'

Reverse geocode by coordinates

curl "https://your-app.up.railway.app/postcodes?lon=-0.127758&lat=51.507351" ```

A browser UI for ad-hoc lookups is served at the root of the public domain.

Why Deploy Postcodes.io on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Postcodes.io on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
View Template
(v1) Simple Medusa Backend
Deploy an ecommerce backend and admin using Medusa

Shahed Nasser