Skip to main content

Server Installation


Operating System

All major operating systems, including Windows, Linux, and macOS, are supported.



We strongly suggest using Yarn 1.x to run and build Casdoor frontend. Using NPM might cause UI styling issues. For more details, see: casdoor#294.


If your network fails to directly sync the Go dependency packages successfully, you need to use a Go proxy by configuring the GOPROXY environment variable. We strongly recommend using:


Casdoor uses XORM to communicate with the database. Based on Xorm Drivers Support, Casdoor currently provides support for the following databases:

  • MySQL
  • MariaDB
  • PostgreSQL
  • CockroachDB
  • SQL Server
  • Oracle
  • SQLite 3
  • TiDB


The source code of Casdoor is hosted on GitHub: Both the Go backend code and React frontend code are contained in a single repository.

NameDescriptionLanguageSource code
FrontendWeb frontend UI for CasdoorJavaScript + React
BackendRESTful API backend for CasdoorGolang + Beego + XORM

Casdoor supports Go Modules. To download the code, simply clone the code using git:

cd path/to/folder
git clone


Configure Database

Casdoor supports MySQL, MSSQL, SQLite3, and PostgreSQL. By default, Casdoor uses MySQL.


Casdoor stores user, node, and topic information in a MySQL database named casdoor. If the database does not exist, it must be created manually. The DB connection string can be specified at:

driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor


Before running Casdoor, you need to manually prepare a database for PostgreSQL, as Casdoor requires selecting a database when opening Postgres with xorm.

Assuming you have already prepared a database called casdoor, you should specify app.conf like this:

driverName = postgres
dataSourceName = "user=postgres password=postgres host=localhost port=5432 sslmode=disable dbname=casdoor"
dbName = casdoor

For PostgreSQL, ensure that dataSourceName has a non-empty dbName and also duplicate the database name for the dbname field as shown in the example above.


CockroachDB can also be used with the PostgreSQL driver and has the same configuration as PostgreSQL.

driverName = postgres
dataSourceName = "user=postgres password=postgres host=localhost port=5432 sslmode=disable dbname=casdoor serial_normalization=virtual_sequence"
dbName = casdoor

For CockroachDB, remember to add serial_normalization=virtual_sequence to the dataSourceName as shown in the example above. Otherwise, you will get an error regarding an existing database whenever the service starts or restarts. Note that this must be added before the database is created.


To configure SQLite3, you should specify app.conf like this:

driverName = sqlite
dataSourceName = "file:casdoor.db?cache=shared"
dbName = casdoor

Via Ini file

Casdoor can be configured via a single file: conf/app.conf, which by default contains the following content:

appname = casdoor
httpport = 8000
runmode = dev
SessionOn = true
copyrequestbody = true
driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor
tableNamePrefix =
showSql = false
redisEndpoint =
defaultStorageProvider =
isCloudIntranet = false
authState = "casdoor"
socks5Proxy = ""
verificationCodeTimeout = 10
initScore = 2000
logPostOnly = true
origin = ""
staticBaseUrl = ""
enableGzip = true
  • appname is the application name, which currently has no practical use.
  • httpport is the port that your backend application is listening on.
  • runmode can be set to dev or prod.
  • SessionOn determines whether to enable session and is enabled by default.
  • driverName, dataSourceName, and dbName were introduced earlier. Please see Configure Database for details.
  • verificationCodeTimeout sets the expiration time of the verification code. After expiration, the user needs to obtain it again.

As a beginner, you only need to modify two items: driverName and dataSourceName based on your database. This database will be used by Casdoor to store all data, including users, organizations, and applications.

  • tableNamePrefix is the prefix of the table when using an adapter.
  • showSql determines whether to show SQL statements on the logger if the log level is greater than INFO.
  • redisEndpoint is the Redis endpoint used by Beego session storage. If this parameter is empty, the session data will be stored locally as files in the ./tmp folder. To use Redis as Beego session storage, the value would be something like: If Redis is deployed locally, you can use localhost:6379. If Redis password is enabled, use,db,password. See more details at:
  • defaultStorageProvider is the default file storage service name. If you need to use file storage services such as avatar upload, you need to set up a storage provider and apply it in your application. See storage for details.
  • isCloudIntranet is used to identify whether your provider endpoint is an intranet endpoint.
  • authState is the authorization application name. This parameter will be checked when logging in.
  • socks5Proxy is the SOCKS proxy server IP address. Set the proxy port because we have Google-related services or use Google, GitHub, Facebook, LinkedIn, or Steam as OAuth Providers, which may be restricted by the network in some areas.
  • initScore is the initial score of each user. Each user has a score attribute. The score is used by Casnode and does not control anything in Casdoor.
  • logPostOnly is used to determine whether only the post method is used to add a record.
  • origin is the origin backend domain name.
  • staticBaseUrl is the address of the static image used when the system initializes the database.
  • enableGzip will accept and respond with gzip encoding if the request header includes Accept-Encoding=gzip.

Via Environment Variables

All configuration items defined by Casdoor in the ini file mentioned above can be configured via environment variables, as well as some of the beego configurations items (httpport, appname).

For example, when you try to start Casdoor, you can use something like this to pass the configuration via environment variables:

appname=casbin go run main.go

In addition, export derivatives are also a possible method. The names of environmental variables should exactly match the names you want to use in the ini file.

Note: configurations in environmental variables can override the configurations in the ini file.


There are currently two methods to start, and you can choose one according to your situation.

Development Mode


Casdoor's Go backend runs on port 8000 by default. You can start the Go backend with the following command:

go run main.go

After the server is successfully running, you can start the frontend part.


Casdoor's frontend is a very classic Create-React-App (CRA) project. It runs on port 7001 by default. Use the following commands to run the frontend:

cd web
yarn install
yarn start

Visit http://localhost:7001 in your browser. Log into the Casdoor dashboard with the default global admin account: built-in/admin.


Production Mode


Build the Casdoor Go backend code into an executable and start it.

For Linux:

go build

For Windows:

go build


Build the Casdoor frontend code into static resources (.html, .js, .css files):

cd web
yarn install
yarn build

Visit http://localhost:8000 in your browser. Log into the Casdoor dashboard with the default global admin account: built-in/admin.


To use another port, please edit conf/app.conf and modify httpport, then restart the Go backend.

Casdoor Port Details

In the dev environment, the frontend is run by yarn run on port 7001, so if you want to go to the Casdoor login page, you need to set the Casdoor link as http://localhost:7001.

In the prod environment, the frontend files are first built by yarn build and served on port 8000, so if you want to go to the Casdoor login page, you need to set the Casdoor link as (If you are using a reverse proxy, you need to set the link as your domain).

Take Our Official Forum Casnode as an Example

Casnode uses Casdoor to handle authentication.

When we are testing Casnode in the dev environment, we set the serverUrl as http://localhost:7001, so when we test the signin and signup functionality using Casdoor, it will go to localhost 7001, which is the Casdoor port.

And when we put Casnode into the prod environment, we set the serverUrl as, so users can sign in or sign up using Casdoor.

Casnode Example