🔍 Developer Error Code Database

Find solutions to common development errors quickly

🌐 Network Errors

ERR_CONNECTION_REFUSED

The connection to the server was refused

Common Causes:

  • Server is not running
  • Wrong port number
  • Firewall blocking connection
  • Server crashed or stopped

Solutions:

1. Verify server is running
ps aux | grep node  # Check if Node.js server is running
netstat -tuln | grep LISTEN  # Check listening ports
2. Check if port is correct

Verify you're connecting to the right port (usually 3000, 8080, etc.)

3. Start your development server
npm start  # or yarn start, npm run dev, etc.

ECONNRESET

Connection reset by peer

Common Causes:

  • Server closed connection unexpectedly
  • Network timeout
  • Firewall/proxy interference
  • Server reached request limit

Solutions:

1. Increase timeout settings
// Node.js
server.timeout = 120000; // 2 minutes

// Axios
axios.get(url, { timeout: 30000 })
2. Check server logs

Look for errors or crashes in your server logs

3. Implement retry logic
// Retry with exponential backoff
const retry = async (fn, retries = 3) => {
  for (let i = 0; i < retries; i++) {
    try {
      return await fn();
    } catch (err) {
      if (i === retries - 1) throw err;
      await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i)));
    }
  }
};

ETIMEDOUT

Connection timed out

Common Causes:

  • Server is too slow to respond
  • Network connectivity issues
  • DNS resolution problems
  • Request timeout too short

Solutions:

1. Increase timeout value
// Fetch API
fetch(url, { signal: AbortSignal.timeout(10000) })

// Axios
axios.get(url, { timeout: 10000 })
2. Check network connectivity
ping google.com
traceroute google.com  # or tracert on Windows
3. Test DNS resolution
nslookup yourdomain.com
dig yourdomain.com

EHOSTUNREACH

No route to host

Common Causes:

  • Host is down or unreachable
  • Incorrect IP address or hostname
  • Network routing issues
  • Firewall blocking access

Solutions:

1. Verify host is reachable
ping hostname
telnet hostname port
2. Check firewall rules

Ensure firewall isn't blocking outbound connections

Linux:

sudo iptables -L
sudo ufw status

Windows:

netsh advfirewall show allprofiles

🔌 Port Errors

EADDRINUSE

Address already in use / Port already in use

Common Causes:

  • Another application is using the port
  • Previous instance didn't terminate properly
  • Multiple servers trying to use same port

Solutions:

1. Find what's using the port

macOS/Linux:

lsof -i :3000  # Replace 3000 with your port
sudo lsof -i :3000  # If permission denied

Windows:

netstat -ano | findstr :3000
# Note the PID in the last column
2. Kill the process

macOS/Linux:

kill -9 PID  # Replace PID with actual process ID
# Or use killport (if installed)
npx kill-port 3000

Windows:

taskkill /PID [PID] /F
3. Or use a different port
# For React
PORT=3001 npm start

# For Node.js/Express
const PORT = process.env.PORT || 3001;

# For Vite
npm run dev -- --port 3001

EACCES (Port)

Permission denied - Cannot bind to port

Common Causes:

  • Trying to use privileged port (<1024) without sudo
  • Insufficient permissions
  • Port protected by system

Solutions:

1. Use a port above 1024

Ports below 1024 require root/admin privileges. Use 3000, 8080, etc.

// Instead of port 80, use 8080
const PORT = 8080;
2. Or run with elevated privileges (not recommended for development)

Linux/macOS:

sudo npm start  # Not recommended

Windows:

Run terminal as Administrator

⚠️ Warning: Running development servers as root/admin is a security risk. Always use non-privileged ports.
3. Allow Node.js to bind to privileged ports (Linux only)
sudo setcap 'cap_net_bind_service=+ep' $(which node)

📦 npm/Yarn Errors

ERESOLVE

Could not resolve dependency

Common Causes:

  • Conflicting dependency versions
  • Peer dependency mismatch
  • Package version incompatibility

Solutions:

1. Use legacy peer deps (npm 7+)
npm install --legacy-peer-deps
2. Force install (use with caution)
npm install --force
⚠️ Warning: --force may install incompatible versions
3. Clear cache and reinstall
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
4. Update package.json manually

Adjust version ranges to resolve conflicts

"dependencies": {
  "react": "^18.0.0",  // Make sure compatible versions
  "react-dom": "^18.0.0"
}

Integrity Checksum Failed

sha512-... integrity checksum failed

Common Causes:

  • Corrupted cache
  • Package registry issues
  • Network interruption during download

Solutions:

1. Clear npm cache
npm cache clean --force
2. Delete lock file and node_modules
rm -rf node_modules package-lock.json
npm install
3. Try different registry
npm install --registry=https://registry.npmjs.org/

ENOENT

No such file or directory

Common Causes:

  • Missing file or directory
  • Incorrect path
  • File deleted or moved
  • Case-sensitive path issues

Solutions:

1. Check if file exists
ls -la path/to/file  # Unix
dir path\to\file     # Windows
2. Verify path spelling and case

On Unix systems, paths are case-sensitive

3. Reinstall if it's a package script
rm -rf node_modules
npm install

EACCES (npm)

Permission denied (npm install)

Common Causes:

  • npm global directory has wrong permissions
  • Installing global package without proper permissions

Solutions:

1. Use npx instead of global install
npx create-react-app my-app  # Instead of global install
2. Fix npm permissions (Linux/macOS)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
3. Or use sudo (not recommended)
sudo npm install -g package-name
⚠️ Warning: Using sudo can cause permission issues later

📚 Git Errors

Fatal: Refusing to Merge Unrelated Histories

fatal: refusing to merge unrelated histories

Common Causes:

  • Merging two independent repositories
  • Fresh clone vs existing local repo
  • Force push created divergent histories

Solutions:

1. Allow unrelated histories
git pull origin main --allow-unrelated-histories
2. Resolve any merge conflicts
git status  # See conflicted files
# Edit files to resolve conflicts
git add .
git commit -m "Merge unrelated histories"

Error: Failed to Push Some Refs

error: failed to push some refs to 'origin'

Common Causes:

  • Remote has commits you don't have locally
  • Someone else pushed before you
  • Branch protection rules

Solutions:

1. Pull before pushing
git pull origin main
# Resolve any conflicts if needed
git push origin main
2. Or use rebase
git pull --rebase origin main
git push origin main
3. Force push (use with extreme caution)
git push --force origin main  # Overwrites remote!
⚠️ Warning: Force push can delete other people's commits. Only use on your own branches.

CONFLICT: Merge Conflict

CONFLICT (content): Merge conflict in file.js

Common Causes:

  • Same lines modified in different branches
  • File deleted in one branch, modified in another

Solutions:

1. View conflicted files
git status
2. Open and resolve conflicts

Look for conflict markers in the file:

<<<<<<< HEAD
Your changes
=======
Their changes
>>>>>>> branch-name
3. Mark as resolved and commit
git add conflicted-file.js
git commit -m "Resolve merge conflict"
4. Or abort the merge
git merge --abort

Permission Denied (publickey)

Permission denied (publickey). fatal: Could not read from remote repository

Common Causes:

  • SSH key not added to GitHub/GitLab
  • SSH key not loaded in ssh-agent
  • Wrong SSH key being used

Solutions:

1. Generate SSH key if you don't have one
ssh-keygen -t ed25519 -C "[email protected]"
2. Add SSH key to ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
3. Copy public key and add to GitHub
cat ~/.ssh/id_ed25519.pub
# Copy the output and add to GitHub Settings > SSH Keys
4. Test SSH connection
5. Or use HTTPS instead
git remote set-url origin https://github.com/username/repo.git

🗄️ Database Errors

Connection Refused (Database)

ECONNREFUSED 127.0.0.1:3306 (or 5432, 27017, etc.)

Common Causes:

  • Database server not running
  • Wrong port number
  • Database not configured to accept connections

Solutions:

1. Check if database is running

MySQL:

sudo systemctl status mysql      # Linux
brew services list               # macOS
mysql.server status             # macOS alternative

PostgreSQL:

sudo systemctl status postgresql  # Linux
brew services list                # macOS

MongoDB:

sudo systemctl status mongod     # Linux
brew services list               # macOS
2. Start the database service
sudo systemctl start mysql       # MySQL
sudo systemctl start postgresql  # PostgreSQL
sudo systemctl start mongod      # MongoDB
3. Verify port in connection string

Default ports: MySQL (3306), PostgreSQL (5432), MongoDB (27017)

Authentication Failed (Database)

Access denied for user / Authentication failed

Common Causes:

  • Wrong username or password
  • User doesn't have access to database
  • Connection from unauthorized host

Solutions:

1. Verify credentials in .env file
DB_HOST=localhost
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
2. Reset database password

MySQL:

mysql -u root -p
ALTER USER 'username'@'localhost' IDENTIFIED BY 'newpassword';
FLUSH PRIVILEGES;

PostgreSQL:

psql -U postgres
ALTER USER username WITH PASSWORD 'newpassword';
3. Grant user permissions
-- MySQL
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';

-- PostgreSQL
GRANT ALL PRIVILEGES ON DATABASE database_name TO username;

Too Many Connections

Too many connections / max_connections reached

Common Causes:

  • Connection pool not properly closed
  • Too many concurrent users
  • Database max_connections setting too low
  • Connection leaks in application code

Solutions:

1. Close connections properly in code
// Node.js with MySQL
connection.end();

// Using pool
pool.query(sql, (err, result) => {
  // Don't forget to release
  connection.release();
});
2. Use connection pooling
const pool = mysql.createPool({
  host: 'localhost',
  user: 'user',
  password: 'password',
  database: 'db',
  connectionLimit: 10
});
3. Increase max_connections (if needed)
-- MySQL
SET GLOBAL max_connections = 200;

-- PostgreSQL (in postgresql.conf)
max_connections = 200

🔧 Build Errors

Module Not Found

Cannot find module 'module-name'

Common Causes:

  • Package not installed
  • Wrong import path
  • Case-sensitive path issues
  • Missing file extension

Solutions:

1. Install missing package
npm install module-name
# or
yarn add module-name
2. Check import path
// Correct relative paths
import Component from './Component';  // Same directory
import Component from '../Component'; // Parent directory

// Node modules
import express from 'express';
3. Reinstall node_modules
rm -rf node_modules package-lock.json
npm install

SyntaxError: Unexpected Token

SyntaxError: Unexpected token <

Common Causes:

  • JSX syntax in non-transpiled file
  • Importing HTML instead of JS
  • Babel/TypeScript not configured
  • Missing file or 404 returning HTML

Solutions:

1. Check file extension for JSX
// Use .jsx or .tsx extension for files with JSX
// Or configure babel to handle .js files with JSX
2. Verify correct import path
// Wrong
import App from './App.html';

// Correct
import App from './App.js';
3. Check network tab for 404s

If importing a file that doesn't exist, you might get HTML error page

JavaScript Heap Out of Memory

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Common Causes:

  • Large build process
  • Memory leak in build scripts
  • Node.js default memory limit too low

Solutions:

1. Increase Node.js memory limit
NODE_OPTIONS="--max-old-space-size=4096" npm run build

# Or in package.json
"scripts": {
  "build": "NODE_OPTIONS=--max-old-space-size=4096 react-scripts build"
}
2. Clear cache before build
npm cache clean --force
rm -rf node_modules .next build
npm install
npm run build

🔐 CORS Errors

Blocked by CORS Policy

Access to fetch at 'URL' has been blocked by CORS policy

Common Causes:

  • Backend not configured to allow frontend origin
  • Missing CORS headers
  • Preflight request failing

Solutions:

1. Enable CORS in backend (Express.js)
const cors = require('cors');

// Allow all origins (development only)
app.use(cors());

// Or specific origin (production)
app.use(cors({
  origin: 'http://localhost:3000',
  credentials: true
}));
2. Spring Boot CORS configuration
@Configuration
public class WebConfig {
  @Bean
  public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurer() {
      @Override
      public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
          .allowedOrigins("http://localhost:3000")
          .allowedMethods("GET", "POST", "PUT", "DELETE");
      }
    };
  }
}
3. Use proxy in development (React)
// package.json
{
  "proxy": "http://localhost:8080"
}

// Then use relative URLs
fetch('/api/data')
4. Or use Vite proxy
// vite.config.js
export default {
  server: {
    proxy: {
      '/api': 'http://localhost:8080'
    }
  }
}

No 'Access-Control-Allow-Origin' Header

No 'Access-Control-Allow-Origin' header is present on the requested resource

Common Causes:

  • Server not sending CORS headers
  • CORS middleware not applied
  • Route-specific CORS not configured

Solutions:

1. Add CORS headers manually (Express)
app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

  if (req.method === 'OPTIONS') {
    return res.sendStatus(200);
  }
  next();
});
2. Django CORS setup
# Install django-cors-headers
pip install django-cors-headers

# settings.py
INSTALLED_APPS = [
    'corsheaders',
    ...
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    ...
]

CORS_ALLOWED_ORIGINS = [
    "http://localhost:3000",
]

😕 No errors found matching your search.

Try different keywords or view all errors

Can't find what you're looking for? Visit our Troubleshooting Center