Did you mean to visit localhost:3000?

Did you mean to visit: http://localhost:3000/?

💡 Pro Tip: Port 3000 is the default for React and Express apps. If you get "port already in use" errors, try using PORT=3001 or kill the existing process.

Quick Commands for Port 3000

Find what's using port 3000:
lsof -i :3000 (Mac/Linux)
netstat -ano | findstr :3000 (Windows)
Kill the process:
kill -9 PID (Mac/Linux)
taskkill /PID PID /F (Windows)
Start with custom port:
PORT=3001 npm start (React)
npm start -- --port 3001 (Vite)
Check if port is available:
nc -z localhost 3000 (Mac/Linux)
Test-NetConnection localhost -Port 3000 (PowerShell)

🚀 Environment Configuration

Configure your development environment properly:

React (.env file):
PORT=3000
BROWSER=none
FAST_REFRESH=true
Express (app.js):
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server running on ${PORT}`);
});

🐳 Docker Configuration for Port 3000

Running your applications in Docker containers:

React Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
Docker run command:
docker run -p 3000:3000 myapp
Docker compose:
ports:
  - "3000:3000"

About Port 3000

Port 3000 is commonly used by:

Common Issues with Port 3000

"Port 3000 is already in use"

This error occurs when another application is already using port 3000. Solutions:

  • Find and close the application using port 3000
  • Use a different port by setting an environment variable:
    • React: PORT=3001 npm start
    • Express: Change the port in your code
  • On Windows, you can find and kill the process: netstat -ano | findstr :3000 then taskkill /PID [PID] /F

✅ Quick Solution

Start React on a different port: PORT=3001 npm start

"Cannot connect to localhost:3000"

If your application is running but you can't connect:

  • Check if your application is actually running
  • Make sure you're not using HTTPS when the server is HTTP
  • Try using 127.0.0.1:3000 instead of localhost:3000
  • Check if a firewall is blocking the connection

"ERR_CONNECTION_REFUSED"

This browser error indicates the server isn't running or accessible:

  • Verify your development server is actually running
  • Check the terminal/console for error messages
  • Try restarting your development server
  • Clear browser cache and cookies
  • Disable browser extensions that might interfere

"Module not found" or Build Errors

When your server starts but shows build errors:

  • Run npm install to ensure all dependencies are installed
  • Clear node_modules and reinstall: rm -rf node_modules && npm install
  • Check for typos in import statements
  • Verify file paths and case sensitivity
  • Update outdated dependencies: npm update

🛠️ Development Tools & Debugging

React DevTools:

Essential browser extension for React debugging

npm install -g react-devtools
Hot Reload Issues:

If changes aren't reflecting:

FAST_REFRESH=true npm start
CHOKIDAR_USEPOLLING=true npm start
Performance Monitoring:

Monitor your app performance:

npm install --save-dev webpack-bundle-analyzer
Network Debugging:

Debug API calls and network requests

console.log('API URL:', process.env.REACT_APP_API_URL)

⚡ Performance Optimization Tips

🔧 Troubleshooting Checklist

Before You Start Debugging:

  1. ✅ Check if Node.js and npm are properly installed: node --version && npm --version
  2. ✅ Verify you're in the correct project directory
  3. ✅ Ensure package.json exists and has the correct scripts
  4. ✅ Check if .env file has correct environment variables
  5. ✅ Verify no conflicting processes are running on port 3000
  6. ✅ Check antivirus/firewall isn't blocking the connection
  7. ✅ Try running in incognito/private browsing mode

🛡️ Security Best Practices

Useful Resources