cds watch — Running the Server

Start and stop the CAP dev server, read the startup output, access the service explorer, and handle common startup errors.

cds watch — Running the CAP Dev Server

cds watch is the primary development command for CAP. It watches your files and restarts the server on every change.

Start the server

cd my-cap-app
cds watch

Understanding the startup output

cds serve all --with-mocks --in-memory?
...
[cds] - model loaded from 2 file(s):
  db/schema.cds
  srv/cat-service.cds

[cds] - connect to db > sqlite { database: ':memory:' }
[cds] - serving CatalogService { path: '/catalog', impl: 'srv/cat-service.js' }

[cds] - server listening on { url: 'http://localhost:4004' }
[cds] - launched at ... in: 842ms
[cds] - [ terminate with ^C ]

Line by line:
- model loaded — which .cds files were compiled
- connect to db — SQLite in-memory (default for local dev)
- serving CatalogService — the OData path and optional JS handler
- localhost:4004 — the URL to open

The service explorer

Open http://localhost:4004 in a browser. You'll see:

Access the OData endpoint directly

http://localhost:4004/catalog/Products
http://localhost:4004/catalog/Products?$top=5&$orderby=name
http://localhost:4004/catalog/Products?$filter=price gt 10

Stop the server

Press Ctrl+C in the terminal.

Common startup errors

Cannot find module '@sap/cds'

npm install   # install project dependencies first

Port 4004 already in use

# macOS / Linux
lsof -ti:4004 | xargs kill

# Windows
netstat -ano | findstr :4004
taskkill /PID <pid> /F

Error: No model found

Your .cds files have a syntax error. Check the line number in the error output.

Useful cds watch flags

cds watch --port 4005          # different port
cds watch --log-level debug    # verbose output (shows SQL queries)
cds watch --profile production # use production config profile
Sign in for progress tracking & Q&A →