Troubleshooting
This guide helps you diagnose and solve common issues with the signing server and order attribution.
Server Issues
Section titled “Server Issues”Server Won’t Start
Section titled “Server Won’t Start”Symptoms:
- Server exits immediately after starting
- Error messages about missing variables
- Port binding errors
Solutions:
-
Check environment variables:
Terminal window # Verify all required variables are setcat .env# Test with explicit variablesPOLYS_POLYMARKET_API_KEY=test \POLYS_POLYMARKET_SECRET=test \POLYS_POLYMARKET_PASSPHRASE=test \POLYS_API_TOKENS=test \./server -
Verify port availability:
Terminal window # Check if port is in usesudo lsof -i :8080sudo netstat -tulpn | grep 8080# Use a different portPOLYS_SERVER_PORT=3000 ./server -
Check Bun installation:
Terminal window bun --version# Reinstall if neededcurl -fsSL https://bun.sh/install | bash -
Review server logs:
Terminal window # systemdsudo journalctl -u polys-server -n 50 -f# Dockerdocker logs polys-server --tail 50 -f# PM2pm2 logs polys-server
Server Crashes or Restarts
Section titled “Server Crashes or Restarts”Symptoms:
- Server stops unexpectedly
- Frequent restarts
- Out of memory errors
Solutions:
-
Check resource usage:
Terminal window # System resourceshtopfree -h# Docker resourcesdocker stats polys-server -
Increase memory limits:
Terminal window # Docker composeservices:polys-server:mem_limit: 1gmem_reservation: 512m# systemdMemoryLimit=1G -
Enable automatic restarts:
Terminal window # systemdRestart=on-failureRestartSec=10# Docker composerestart: unless-stopped# PM2pm2 start server --name polys-server --max-restarts 10
Port Already in Use
Section titled “Port Already in Use”Error: EADDRINUSE: address already in use
Solutions:
-
Find and kill the process:
Terminal window # Find processsudo lsof -i :8080# Kill processsudo kill -9 <PID> -
Use a different port:
Terminal window export POLYS_SERVER_PORT=3000./server -
Configure server to listen on all interfaces:
Terminal window export POLYS_SERVER_HOSTNAME=0.0.0.0
Authentication Issues
Section titled “Authentication Issues”Bearer Token Authentication Fails
Section titled “Bearer Token Authentication Fails”Error: 401 Unauthorized or 403 Forbidden
Solutions:
-
Verify token matches:
Terminal window # Server side (comma-separated list)echo $POLYS_API_TOKENS# Client side (single token that's in the server's list)echo $SIGNING_SERVER_TOKEN# Client token must be one of the tokens in the server's comma-separated list -
Check Authorization header:
Terminal window # Correct formatAuthorization: Bearer your_token_here# Test with curlcurl -X POST http://localhost:8080/api/sign \-H "Authorization: Bearer your_token" \-H "Content-Type: application/json" \-d '{"method":"GET","path":"/markets"}' -
Regenerate API token:
Terminal window # Generate new tokenopenssl rand -base64 32# Add to server's token list (supports multiple tokens)export POLYS_API_TOKENS=old_token,new_token# Update client to use new tokenexport SIGNING_SERVER_TOKEN=new_token# After all clients are updated, remove old token from serverexport POLYS_API_TOKENS=new_token
API Credential Errors
Section titled “API Credential Errors”Error: Invalid API credentials or signature validation failures
Solutions:
-
Verify credentials format:
Terminal window # API key should be alphanumericecho $POLYS_POLYMARKET_API_KEY# Secret should be Base64 encodedecho $POLYS_POLYMARKET_SECRET | base64 -d# Passphrase is plain textecho $POLYS_POLYMARKET_PASSPHRASE -
Check credentials on Polymarket:
- Log into Polymarket Builder Program dashboard
- Verify API credentials are active
- Regenerate if necessary
-
Test credentials separately:
Terminal window # Test signing endpoint with known-good request# Use any token from your POLYS_API_TOKENS listcurl -X POST http://localhost:8080/api/sign \-H "Authorization: Bearer your_token_here" \-H "Content-Type: application/json" \-d '{"method":"GET","path":"/markets"}'
Network Issues
Section titled “Network Issues”Cannot Reach Signing Server
Section titled “Cannot Reach Signing Server”Error: ECONNREFUSED, ETIMEDOUT, or Network error
Solutions:
-
Verify server is running:
Terminal window # Check health endpointcurl http://localhost:8080/health# Check processps aux | grep serversystemctl status polys-serverdocker ps | grep polys-server -
Check network connectivity:
Terminal window # From client machineping your-server.com# Test port connectivitytelnet your-server.com 8080nc -zv your-server.com 8080 -
Review firewall rules:
Terminal window # Check firewall statussudo ufw statussudo iptables -L# Allow port 8080sudo ufw allow 8080/tcpsudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT -
Check DNS resolution:
Terminal window # Verify domain resolvesnslookup your-server.comdig your-server.com# Test with IP directlycurl http://1.2.3.4:8080/health
SSL/TLS Certificate Errors
Section titled “SSL/TLS Certificate Errors”Error: certificate verify failed or SSL handshake failed
Solutions:
-
Verify certificate validity:
Terminal window # Check certificateopenssl s_client -connect your-server.com:443# Verify expirationecho | openssl s_client -connect your-server.com:443 2>/dev/null | \openssl x509 -noout -dates -
Update certificates:
Terminal window # Let's Encryptsudo certbot renew# Copy new certificatessudo cp /etc/letsencrypt/live/your-domain/fullchain.pem /path/to/certs/sudo cp /etc/letsencrypt/live/your-domain/privkey.pem /path/to/certs/ -
Disable SSL verification (development only):
// NOT for productionprocess.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
Monitoring and Debugging
Section titled “Monitoring and Debugging”Client side:
const client = new Polymarket({ clob: { wallet, credentials, attributor: { url: process.env.SIGNING_SERVER_URL!, token: process.env.SIGNING_SERVER_TOKEN!, }, debug: true, // Enable debug logging },});Health Monitoring Script
Section titled “Health Monitoring Script”Create health-check.sh:
#!/bin/bash
SERVER_URL="http://localhost:8080"BEARER_TOKEN="your_token"
# Check health endpointHEALTH=$(curl -s -o /dev/null -w "%{http_code}" $SERVER_URL/health)
if [ "$HEALTH" != "200" ]; then echo "❌ Server health check failed: HTTP $HEALTH" # Send alert (email, Slack, PagerDuty, etc.) exit 1fi
echo "✅ Server is healthy"exit 0Run as cron job:
*/5 * * * * /path/to/health-check.sh >> /var/log/health-check.log 2>&1Request Tracing
Section titled “Request Tracing”Add request IDs for tracing:
import { randomUUID } from "crypto";
async function createOrderWithTracing(orderParams: any) { const requestId = randomUUID();
console.log(`[${requestId}] Creating order:`, { side: orderParams.side, size: orderParams.size, price: orderParams.price, });
try { const order = await client.order.createOrder(orderParams); console.log(`[${requestId}] Order created:`, order.orderId); return order; } catch (error) { console.error(`[${requestId}] Order failed:`, error); throw error; }}Getting Help
Section titled “Getting Help”If you’re still experiencing issues:
-
Check the logs:
- Server logs: Look for error messages and stack traces
- Client logs: Enable debug mode to see request/response details
- System logs: Check systemd/Docker logs
-
Test components individually:
- Server health endpoint
- Signing endpoint with curl
- Client without attribution
- Client with attribution
-
Review configuration:
- Environment variables
- Network settings
- Firewall rules
- SSL certificates
-
Search existing issues:
- GitHub Issues
- Common error messages
- Configuration examples
-
Create an issue:
- Include error messages
- Provide configuration (redact sensitive data)
- Describe steps to reproduce
- Share relevant logs
See Also
Section titled “See Also”- Setup Guide - Initial configuration
- Deployment Guide - Production deployment
- Client Usage - Integration examples
- Error Handling Guide - Error handling patterns