Skip to content
Discussion options

You must be logged in to vote

This is a Docker networking issue. Inside your web container, localhost:3000 refers to the container itself, not your api service.

Solution

1. Use Docker service names for internal URLs

In your Docker Compose, services communicate via their service names, not localhost. So http://api:3000 instead of http://localhost:3000.

2. Configure next.config.js for Docker

// next.config.js
module.exports = {
  images: {
    remotePatterns: [
      {
        protocol: 'http',
        hostname: 'api',  // Docker service name
        port: '3000',
        pathname: '/uploads/**',
      },
      {
        protocol: 'http',
        hostname: 'localhost',  // For local development
        port: '3000',

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@apudiu
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@apudiu
Comment options

@prafuldivani
Comment options

@tomihq
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by apudiu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
7 participants