You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker部署Magento 2后无法访问https://magento2.test,寻求本地访问指引

Troubleshooting https://magento2.test Access Issues with Mark Shust's Docker Magento Setup

Hey there! I’ve walked through this exact setup dozens of times, so let’s break down the most common fixes to get your local Magento 2 instance up and accessible:

1. Verify Your Local Hosts File Entry

First, your system needs to know where to route magento2.test—this is handled by the hosts file.

  • On macOS/Linux: Open a terminal and run sudo nano /etc/hosts. Add this line at the bottom:
    127.0.0.1 magento2.test
    
    Save with Ctrl+O, exit with Ctrl+X.
  • On Windows: Open Notepad as Administrator, then open C:\Windows\System32\drivers\etc\hosts. Add the same line above, then save.

2. Check if Docker Containers Are Running

If your containers aren’t active, nothing will respond. Run this command in your project directory:

docker-compose ps

Look for all core services (web, db, php-fpm, etc.) to show a status of Up. If any are Exited or Restarting, restart them with:

docker-compose up -d

You can also check web container logs for critical errors like port conflicts:

docker-compose logs web

3. Confirm Port Mapping & Availability

The default setup uses ports 80 (HTTP) and 443 (HTTPS). If another service (like Apache, Nginx, or even a messaging app) is using these ports, Docker can’t bind to them.

  • Check your docker-compose.yml for the web service’s port section. It should look something like:
    ports:
      - "80:80"
      - "443:443"
    
  • If ports are occupied, modify the mappings (e.g., "8080:80" and "8443:443"), restart containers, then visit https://magento2.test:8443 instead.

4. Trust the Local SSL Certificate

Browsers often block untrusted SSL certificates, which can manifest as a "page not found" error instead of a clear certificate warning.

  • Locate the generated certificate in your project’s ssl directory (usually magento2.test.crt).
  • macOS: Double-click the certificate, open "Keychain Access", find the certificate, right-click it, and select "Get Info" > "Trust" > "Always Trust".
  • Windows: Right-click the certificate, choose "Install Certificate", select "Local Machine", then "Place all certificates in the following store" > "Trusted Root Certification Authorities".
  • Linux: Copy the certificate to /usr/local/share/ca-certificates/, then run sudo update-ca-certificates.

5. Test Inside the Docker Web Container

To rule out local network issues, jump into the web container and test access internally:

docker-compose exec web bash

Once inside, run:

curl https://magento2.test

If you see Magento’s HTML output, the container is working fine—your issue is with local DNS, certificates, or port forwarding.

6. Flush DNS & Browser Caches

Old cached DNS records or browser data can block access:

  • Browser: Open an incognito/private window and try accessing the URL again, or clear your cache with Ctrl+Shift+Delete.
  • Local DNS:
    • macOS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    • Windows: ipconfig /flushdns
    • Linux: sudo systemctl restart systemd-resolved (adjust for your distro if needed)

内容的提问来源于stack exchange,提问作者LuDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:43:43