Troubleshooting Guide
Solutions to common issues you might encounter with FlatWP.
Quick Diagnostic Steps
Before diving into specific issues, try these general diagnostic steps:
-
Check the basics
# Verify Node.js version
node --version # Should be 20.0+
# Check if WordPress is accessible
curl https://your-wordpress-site.com/graphql
# Verify environment variables
cat .env.local -
Clear caches
# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules
npm install
# Rebuild
npm run build -
Check logs
- Browser console (F12 → Console tab)
- Terminal output during build
- WordPress debug.log (if enabled)
Installation Issues
Cannot Install Dependencies
Error: npm install fails with permission errors
Solutions:
# Fix npm permissions (macOS/Linux)
sudo chown -R $USER:$USER ~/.npm
sudo chown -R $USER:$USER node_modules
# Or use nvm to avoid permission issues
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 20
nvm use 20
Error: ERESOLVE unable to resolve dependency tree
Solutions:
# Use legacy peer deps
npm install --legacy-peer-deps
# Or use pnpm (recommended)
npm install -g pnpm
pnpm install
Node Version Mismatch
Error: "The engine 'node' is incompatible"
Solution:
# Check required version in package.json
cat package.json | grep engines
# Install correct version with nvm
nvm install 20
nvm use 20
nvm alias default 20
WordPress Connection Issues
GraphQL Endpoint Not Found
Error: "Failed to fetch from WordPress GraphQL endpoint"
Diagnostic:
# Test endpoint directly
curl https://your-wordpress-site.com/graphql
# Should return GraphQL introspection query
Solutions:
-
WPGraphQL not installed
- Go to WordPress admin → Plugins → Add New
- Search "WPGraphQL"
- Install and activate
-
Wrong URL in .env.local
# Wrong
NEXT_PUBLIC_WORDPRESS_API_URL=https://yoursite.com
# Correct
NEXT_PUBLIC_WORDPRESS_API_URL=https://yoursite.com/graphql -
WordPress not publicly accessible
- Check if WordPress is behind firewall
- Verify DNS is correct
- Test in browser:
https://yoursite.com/graphql
-
Permalink settings
- Go to Settings → Permalinks in WordPress
- Click "Save Changes" to flush rewrite rules
CORS Errors
Error: "Access-Control-Allow-Origin header missing"
Solution: Add to WordPress wp-config.php (before "That's all, stop editing!"):
// Development
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
}
exit(0);
}
Production: Use specific origin:
header('Access-Control-Allow-Origin: https://yoursite.com');
header('Access-Control-Allow-Credentials: true');
Authentication Errors
Error: "GraphQL request not authorized"
Solutions:
-
Make sure endpoints are public
- WPGraphQL should allow public queries by default
- Check Settings → GraphQL → "Public Introspection"
-
For protected content
// Add authentication to GraphQL client
const client = new ApolloClient({
uri: process.env.NEXT_PUBLIC_WORDPRESS_API_URL,
headers: {
Authorization: `Bearer ${token}`,
},
});
Build & Development Issues
Build Fails with TypeScript Errors
Error: "Type 'X' is not assignable to type 'Y'"
Solutions:
-
Regenerate GraphQL types
npm run graphql:codegen -
Check TypeScript version
npm list typescript
# Should match version in package.json -
Clear TypeScript cache
rm -rf .next
rm -rf node_modules/.cache
npm run build
Development Server Won't Start
Error: "Port 3000 is already in use"
Solutions:
# Find process using port 3000
lsof -i :3000
# Kill the process
kill -9 <PID>
# Or use different port
PORT=3001 npm run dev
Error: "Cannot find module"
Solutions:
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Check import paths
# Wrong: import Component from 'components/Button'
# Right: import Component from '@/components/Button'
Hot Reload Not Working
Issue: Changes don't appear without manual refresh
Solutions:
-
Check file watching limits (Linux):
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p -
Restart dev server
# Stop with Ctrl+C
npm run dev -
Check for syntax errors
- Look for errors in terminal
- Check browser console
Content & GraphQL Issues
GraphQL Types Not Generated
Error: "Cannot find module './graphql/generated'"
Solutions:
# Generate types
npm run graphql:codegen
# If it fails, check:
# 1. WordPress is accessible
# 2. WPGraphQL is activated
# 3. .env.local has correct URL
# Test endpoint manually
curl https://your-wordpress-site.com/graphql \
-H "Content-Type: application/json" \
-d '{"query":"{ __typename }"}'
Error: "GraphQL schema loading failed"
Solutions:
-
Check WordPress accessibility
- Test in browser
- Verify no authentication required
-
Verify .env.local
NEXT_PUBLIC_WORDPRESS_API_URL=https://yoursite.com/graphql -
Check codegen.ts configuration
schema: process.env.NEXT_PUBLIC_WORDPRESS_API_URL,
ACF Fields Not Appearing in GraphQL
Issue: Custom fields don't show up in GraphQL schema
Solutions:
-
Install WPGraphQL for ACF
- Download from GitHub
- Install and activate
-
Enable "Show in GraphQL" for field groups
- Edit field group in ACF
- Check "Show in GraphQL" option
- Set GraphQL Field Name
-
Flush permalinks
- Go to Settings → Permalinks
- Click "Save Changes"
-
Check field group location rules
- Make sure fields are assigned to post type
- Verify post type is in GraphQL schema
Content Not Updating
Issue: Changes in WordPress don't appear on Next.js site
Solutions:
-
Check webhook configuration
- WordPress → FlatWP → Settings
- Verify Next.js URL is correct
- Confirm secrets match .env.local
- Enable webhooks checkbox
-
Test webhook manually
curl -X POST http://localhost:3000/api/revalidate \
-H "Content-Type: application/json" \
-d '{
"secret": "your-revalidation-secret",
"paths": ["/", "/blog"]
}' -
Check revalidation settings
- For development: Manual revalidation
- For production: Automatic via webhooks
-
Clear cache manually
rm -rf .next/cache
npm run build
Image Issues
Images Not Loading
Error: "Invalid src prop" or images show as broken
Solutions:
-
Update next.config.ts
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'your-wordpress-site.com',
pathname: '/wp-content/uploads/**',
},
],
}, -
Check image URLs in WordPress
- Verify images are uploaded
- Test URL in browser
- Ensure no hotlink protection
-
Verify image field returns correct data
featuredImage {
node {
sourceUrl
altText
}
}
Images Load Slowly
Issue: Images take long to load or aren't optimized
Solutions:
-
Use Next.js Image component
import Image from 'next/image';
<Image
src={imageUrl}
alt={altText}
width={800}
height={600}
placeholder="blur"
blurDataURL={blurData}
/> -
Enable blur placeholders in WordPress
- FlatWP plugin generates these automatically
- Check if plugin is activated
-
Optimize images before upload
- Use tools like TinyPNG
- Recommended: max 2000px wide
- Format: WebP or JPEG
Plugin Issues
FlatWP Dashboard Won't Load
Issue: Blank screen or "Loading..." never finishes
Solutions:
-
Build the React app
cd wp-content/plugins/flatwp-react/admin-react
npm install
npm run build -
Check file permissions
# Folders should be 755, files 644
chmod -R 755 wp-content/plugins/flatwp-react
find wp-content/plugins/flatwp-react -type f -exec chmod 644 {} \; -
Check browser console
- Press F12 → Console
- Look for JavaScript errors
- Check Network tab for failed requests
-
Verify PHP version
- FlatWP requires PHP 7.4+
- Check:
php -v
Connection Status Shows Disconnected
Issue: Red "Disconnected" status in WordPress dashboard
Solutions:
-
Verify Next.js is running
# Check if development server is running
curl http://localhost:3000 -
Test revalidation endpoint
curl -X POST http://localhost:3000/api/revalidate \
-H "Content-Type: application/json" \
-d '{
"secret": "your-secret",
"paths": ["/"]
}'
# Should return: {"revalidated": true} -
Check secrets match
- WordPress plugin settings
- .env.local file
- Must be identical
-
Firewall issues
- WordPress server must reach Next.js server
- Check firewall rules
- For localhost, use 127.0.0.1 not localhost
Webhooks Not Working
Issue: Manual updates work but automatic webhooks don't
Solutions:
-
Check webhook logs
- WordPress → FlatWP → Logs
- Look for failed webhook attempts
-
Verify webhook URL
- Should be:
https://yoursite.com/api/revalidate - Not:
https://yoursite.com/revalidate
- Should be:
-
Test with curl
curl -X POST https://yoursite.com/api/revalidate \
-H "Content-Type: application/json" \
-d '{
"secret": "production-secret",
"paths": ["/", "/blog/test-post"]
}' -
Check WordPress cron
# Webhooks use WordPress cron
# Test if cron is working
wp cron test # Using WP-CLI
Deployment Issues
Vercel Build Fails
Error: Build fails on Vercel but works locally
Solutions:
-
Check environment variables
- Vercel dashboard → Settings → Environment Variables
- Add all variables from .env.local
- Apply to all environments
-
Verify Node version
- Vercel dashboard → Settings → General
- Set Node.js Version to 20.x
-
Check build logs
- Look for specific error message
- Common issues:
- Missing environment variables
- WordPress not accessible from Vercel
- GraphQL codegen failures
-
Ignore build errors (temporary):
// next.config.ts
typescript: {
ignoreBuildErrors: false, // Set to true temporarily
},
eslint: {
ignoreDuringBuilds: false, // Set to true temporarily
},
Production Site Shows 404 Errors
Issue: Pages work locally but show 404 in production
Solutions:
-
Check generateStaticParams
// app/blog/[slug]/page.tsx
export async function generateStaticParams() {
const posts = await getPosts();
return posts.map((post) => ({
slug: post.slug,
}));
} -
Verify fallback configuration
export const dynamicParams = true; // Allow dynamic routes -
Check WordPress content
- Ensure posts are published
- Verify slugs match
-
Rebuild site
- Push to trigger new deployment
- Or manually redeploy in Vercel
Slow Performance in Production
Issue: Site is slow despite optimizations
Solutions:
-
Check Core Web Vitals
# Run Lighthouse audit
npx lighthouse https://yoursite.com --view -
Optimize images
- Use WebP format
- Proper sizing (don't upload 4000px images)
- Enable blur placeholders
-
Review ISR settings
// Adjust revalidation times
export const revalidate = 300; // 5 minutes -
Enable analytics
- Vercel Analytics
- Monitor actual performance data
-
Optimize WordPress
- Use caching plugin (WP Rocket)
- Enable object caching (Redis)
- Optimize GraphQL queries
Getting More Help
Before Asking for Help
Provide this information:
-
Environment details
node --version
npm --version
cat package.json | grep "next" -
Error messages
- Full error from terminal
- Browser console errors
- WordPress debug.log entries
-
What you've tried
- Steps to reproduce
- Solutions attempted
- Relevant configuration
Where to Get Help
-
Search existing issues
-
Ask in GitHub Discussions
- Include error details
- System information
- Steps to reproduce
-
Report bugs
- Open an issue
- Provide reproduction steps
- Include environment details
Debug Mode
Enable detailed logging:
# .env.local
DEBUG=true
NEXT_PUBLIC_DEBUG=true
// Add to components for debugging
console.log('Debug info:', {
data,
props,
state,
});
WordPress debug mode (wp-config.php):
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('GRAPHQL_DEBUG', true);
Common Error Messages Explained
"Module not found: Can't resolve '@/components/...'"
Cause: Path alias not configured or wrong import
Fix: Check tsconfig.json:
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
"Error: Invalid src prop on next/image"
Cause: Image hostname not allowed in next.config.ts
Fix: Add to remotePatterns in next.config.ts
"Error: ECONNREFUSED connecting to GraphQL endpoint"
Cause: WordPress server not accessible
Fix:
- Check WordPress is online
- Verify URL in .env.local
- Test with curl
"Warning: Each child in a list should have a unique 'key' prop"
Cause: Missing key prop in mapped components
Fix:
{items.map((item, index) => (
<div key={item.id || index}> // Add key
{item.content}
</div>
))}
Still Stuck?
If you've tried everything and still have issues:
-
Create minimal reproduction
- Isolate the problem
- Remove unrelated code
- Test in fresh install if possible
-
Check recent changes
- What did you change recently?
- Try reverting to last working state
- Use git to see differences
-
Ask for help
- GitHub Discussions
- Provide all requested information
- Be patient - the community is volunteer-based
We're here to help! 🚀