Datacenters are one of the important global energy consumers and carbon producers. However, their tight service level requirements prevent easy integration with highly variable renewable energy sources. Short-term green energy prediction can mitigate this variability. In this work, we first explore the existing short-term solar and wind energy prediction methods, and then leverage prediction to allocate and migrate workloads across geographically distributed datacenters to reduce brown energy consumption costs. Unlike previous works, we also study the impact of wide area networks (WAN) on datacenters, and investigate the use of green energy prediction to power WANs. Finally, we present two different studies connecting datacenters and WANs: the case where datacenter operators own and manage their WAN and the case where datacenters lease networks from WAN providers. The results show that prediction enables up to 90% green energy utilization, a 3x improvement over the existing methods. The cost minimization algorithm reduces expenses by up to 16% and increases performance by 27% when migrating workloads across datacenters. Furthermore, the savings increase up to 30% compared with no migration when servers are made energy-proportional. Finally, in the case of leasing the WAN, energy proportionality in routers can in-crease the profit of network providers by 1.6x.