2018-11-20 20:34:42 +01:00
---
id: getting_started
title: Getting Started
---
2016-09-29 23:08:36 +02:00
2016-12-02 17:47:13 +01:00
## Requirements
2016-11-30 21:46:40 +01:00
2020-12-03 21:09:16 +01:00
You will need:
2016-11-30 21:46:40 +01:00
2020-12-03 21:09:16 +01:00
- [**Node.js** ](https://nodejs.org/en/download/ ) (version 12 or later)
- [**PostgreSQL** ](https://www.postgresql.org/download/ ) (version 10 or later)
- [Create an unleash user and database ](./developer-guide.md ).
2016-12-02 17:47:13 +01:00
2020-12-03 21:09:16 +01:00
## Start Unleash server
2016-12-02 17:47:13 +01:00
2020-12-03 21:09:16 +01:00
Whichever option you choose to start Unleash, you must specify a database URI (it can be set in the environment variable DATABASE_URL).
2018-11-22 11:20:28 +01:00
2020-12-03 21:09:16 +01:00
Once the server has started, you will see the message:
2020-12-15 13:18:38 +01:00
```sh
2020-12-03 21:09:16 +01:00
Unleash started on http://localhost:4242
```
2016-09-29 23:08:36 +02:00
2020-12-03 21:09:16 +01:00
### Option one - from a terminal/bash shell
2016-09-29 23:08:36 +02:00
2020-12-15 13:18:38 +01:00
```sh
2020-12-03 21:09:16 +01:00
npm install unleash-server -g
unleash -d postgres://unleash_user:password@localhost:5432/unleash -p 4242
2016-09-29 23:08:36 +02:00
```
2020-12-03 21:09:16 +01:00
### Option two - from Node.js
2018-11-22 11:20:28 +01:00
2020-12-03 21:09:16 +01:00
1. Create a new folder/directory on your development computer.
2. From a terminal/bash shell, install the dependencies:
2016-09-29 23:08:36 +02:00
2020-12-15 13:18:38 +01:00
```sh
npm init
npm install unleash-server --save
```
3. Create a file called _server.js_ , paste the following into it and save.
```js
const unleash = require('unleash-server');
unleash
.start({
databaseUrl: 'postgres://unleash_user:password@localhost:5432/unleash',
port: 4242,
})
.then(unleash => {
console.log(
`Unleash started on http://localhost:${unleash.app.get('port')}` ,
);
});
```
4. Run _server.js_ :
```sh
node server.js
```
2020-12-03 21:09:16 +01:00
### Option three - use Docker
2021-01-27 20:11:41 +01:00
[View the image on dockerhub ](https://hub.docker.com/r/unleashorg/unleash-server/ )
#### Docker-compose
1. Clone the [unleash-docker ](https://github.com/Unleash/unleash-docker ) repository.
2. Run `docker-compose build` in repository root folder.
3. Run `docker-compose up` in repository root folder.
#### Manually
1. Create a network by running `docker create network unleash`
2. Run
2020-12-03 21:09:16 +01:00
2020-12-15 13:18:38 +01:00
```sh
2021-01-27 20:11:41 +01:00
docker run -e POSTGRES_PASSWORD={INSERT_PASSWORD} -e POSTGRES_USER={INSERT_USER} -e POSTGRES_DB=unleash --network unleash postgres
docker run -p 4242:4242 --network unleash -e DATABASE_URL=postgres://{INSERT_USER}:{INSERT_PASSWORD}@postgres:5432/unleash unleashorg/unleash-server
2016-09-29 23:08:36 +02:00
```
2016-12-02 17:47:13 +01:00
2020-12-03 21:09:16 +01:00
## Test your server and create a sample API call
Once the Unleash server has started, go to [localhost:4242 ](http://localhost:4242 ) in your browser. If you see a list of example feature toggles, try modifying one of them with [curl ](https://curl.se/ ) from a terminal/bash shell:
2020-12-15 13:18:38 +01:00
```
2020-12-03 21:09:16 +01:00
curl --location --request PUT 'http://localhost:4242/api/admin/features/Feature.A' --header 'Content-Type: application/json' --data-raw '{\
"name": "Feature.A",\
"description": "Dolor sit amet.",\
"type": "release",\
"enabled": false,\
"stale": false,\
"strategies": [\
{\
"name": "default",\
"parameters": {}\
}\
]\
}'\
2017-08-04 16:03:15 +02:00
```
2021-02-19 11:13:25 +01:00
## Version check
- Unleash checks that it uses the latest version by making a call to https://version.unleash.run.
- This is a cloud function storing instance id to our database for statistics.
- This request includes a unique instance id for your server.
- If you do not wish to check for upgrades define the environment variable `CHECK_VERSION` to anything else other than `true` before starting, and Unleash won't make any calls
- `export CHECK_VERSION=false`