How to deploy Hastebin on DreamCompute

Hastebin is a simple self-hosted pastebin alternative.

Setting up a server

The first step to deploying Hastebin is to launch a server to run it on. For example in this tutorial, an Ubuntu Xenial server is used. Read How to launch an instance using the DreamCompute dashboard for information on how to do this. You also need to expose port 8080 to incoming traffic, as that is blocked by default. Read How to configure access and security for DreamCompute instances for information on how to do this.

Installing dependencies


Deploying Hastebin as a service (as done in this article) requires you to have root permissions. In order to start a root shell type sudo su -.

Once you have your server up and running the next step is to install all of Hastebin’s dependencies:

[root@server]# apt-get update
[root@server]# apt-get install nodejs npm

Next you must symlink /usr/bin/nodejs to /usr/bin/node because Hastebin will try to use that path. Most Linux distributions install nodejs in /usr/bin/node. This step is only necessary on Ubuntu servers since it doesn’t install nodejs in /usr/bin/node because of another package.

[root@server]# ln -s /usr/bin/nodejs /usr/bin/node

Installing Hastebin

Now that all the dependencies are installed the next step is to download Hastebin and run it. To clone Hastebin using git, run:

[root@server]# git clone /srv/haste-server

Then to install the application, run:

[root@server]# cd /srv/haste-server
[root@server]# npm install



Now comes the configuration of Hastebin. By default it runs on port 7777. Change it to run on port 8080 by editing /srv/haste-server/config.js:

"port" : 7777,

should be changed to:

"port" : 8080,


Read How to configure access and security for DreamCompute instances for information on how to open port 8080 to traffic.


By default Hastebin uses redis to store its data, we’re going to use a simpler solution, flat files. Edit config.js and delete the configuration for redis:

"storage": {
  "type": "redis",
  "host": "",
  "port": 6379,
  "db": 2,
  "expire": 2592000

and replace it with the configuration for using flat files:

"storage": {
  "type": "file",
  "path": "./data"


Flat files will not scale as well as a database will, so if you expect to have lots of users, be sure to use a database for your data.

Creating a systemd service

The best way to run Hastebin is to create a systemd service for it and create a user for it to run as. To create a systemd service copy the following into /etc/systemd/system/haste-server.service.

Description=haste-server (online code snippet sharing tool)

ExecStart=/usr/bin/node server.js


Next create the user for haste-server to run as.

[root@server]# adduser --system --home=/srv/haste-server --group haste-server

Now there is an ‘haste-server’ user, change the permissions of /srv/haste-server so that it has access to the directory.

[root@server]# chown -R haste-server:haste-server /srv/haste-server

Starting Hastebin

Finally start the service and set it to start at boot:

[root@server]# systemctl enable haste-server
[root@server]# systemctl start haste-server

Hastebin is now running. Confirm it works by going to http://IP:8080. Make sure to replace “IP” with the IP address of your server.


Did this article answer your questions?

Article last updated .